Commit c797ce16 authored by Peter Delevoryas's avatar Peter Delevoryas Committed by David S. Miller

net/ncsi: Simplify Kconfig/dts control flow

Background:

1. CONFIG_NCSI_OEM_CMD_KEEP_PHY

If this is enabled, we send an extra OEM Intel command in the probe
sequence immediately after discovering a channel (e.g. after "Clear
Initial State").

2. CONFIG_NCSI_OEM_CMD_GET_MAC

If this is enabled, we send one of 3 OEM "Get MAC Address" commands from
Broadcom, Mellanox (Nvidida), and Intel in the *configuration* sequence
for a channel.

3. mellanox,multi-host (or mlx,multi-host)

Introduced by this patch:

https://lore.kernel.org/all/20200108234341.2590674-1-vijaykhemka@fb.com/

Which was actually originally from cosmo.chou@quantatw.com:

https://github.com/facebook/openbmc-linux/commit/9f132a10ec48db84613519258cd8a317fb9c8f1b

Cosmo claimed that the Nvidia ConnectX-4 and ConnectX-6 NIC's don't
respond to Get Version ID, et. al in the probe sequence unless you send
the Set MC Affinity command first.

Problem Statement:

We've been using a combination of #ifdef code blocks and IS_ENABLED()
conditions to conditionally send these OEM commands.

It makes adding any new code around these commands hard to understand.

Solution:

In this patch, I just want to remove the conditionally compiled blocks
of code, and always use IS_ENABLED(...) to do dynamic control flow.

I don't think the small amount of code this adds to non-users of the OEM
Kconfigs is a big deal.
Signed-off-by: default avatarPeter Delevoryas <peter@pjd.dev>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f9672265
...@@ -689,8 +689,6 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, ...@@ -689,8 +689,6 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc,
return 0; return 0;
} }
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY)
static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca) static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca)
{ {
unsigned char data[NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN]; unsigned char data[NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN];
...@@ -716,10 +714,6 @@ static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca) ...@@ -716,10 +714,6 @@ static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca)
return ret; return ret;
} }
#endif
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC)
/* NCSI OEM Command APIs */ /* NCSI OEM Command APIs */
static int ncsi_oem_gma_handler_bcm(struct ncsi_cmd_arg *nca) static int ncsi_oem_gma_handler_bcm(struct ncsi_cmd_arg *nca)
{ {
...@@ -856,8 +850,6 @@ static int ncsi_gma_handler(struct ncsi_cmd_arg *nca, unsigned int mf_id) ...@@ -856,8 +850,6 @@ static int ncsi_gma_handler(struct ncsi_cmd_arg *nca, unsigned int mf_id)
return nch->handler(nca); return nch->handler(nca);
} }
#endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */
/* Determine if a given channel from the channel_queue should be used for Tx */ /* Determine if a given channel from the channel_queue should be used for Tx */
static bool ncsi_channel_is_tx(struct ncsi_dev_priv *ndp, static bool ncsi_channel_is_tx(struct ncsi_dev_priv *ndp,
struct ncsi_channel *nc) struct ncsi_channel *nc)
...@@ -1039,20 +1031,18 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) ...@@ -1039,20 +1031,18 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
goto error; goto error;
} }
nd->state = ncsi_dev_state_config_oem_gma; nd->state = IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC)
? ncsi_dev_state_config_oem_gma
: ncsi_dev_state_config_clear_vids;
break; break;
case ncsi_dev_state_config_oem_gma: case ncsi_dev_state_config_oem_gma:
nd->state = ncsi_dev_state_config_clear_vids; nd->state = ncsi_dev_state_config_clear_vids;
ret = -1;
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC)
nca.type = NCSI_PKT_CMD_OEM; nca.type = NCSI_PKT_CMD_OEM;
nca.package = np->id; nca.package = np->id;
nca.channel = nc->id; nca.channel = nc->id;
ndp->pending_req_num = 1; ndp->pending_req_num = 1;
ret = ncsi_gma_handler(&nca, nc->version.mf_id); ret = ncsi_gma_handler(&nca, nc->version.mf_id);
#endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */
if (ret < 0) if (ret < 0)
schedule_work(&ndp->work); schedule_work(&ndp->work);
...@@ -1404,7 +1394,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) ...@@ -1404,7 +1394,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
schedule_work(&ndp->work); schedule_work(&ndp->work);
break; break;
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC)
case ncsi_dev_state_probe_mlx_gma: case ncsi_dev_state_probe_mlx_gma:
ndp->pending_req_num = 1; ndp->pending_req_num = 1;
...@@ -1429,7 +1418,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) ...@@ -1429,7 +1418,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
nd->state = ncsi_dev_state_probe_cis; nd->state = ncsi_dev_state_probe_cis;
break; break;
#endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */
case ncsi_dev_state_probe_cis: case ncsi_dev_state_probe_cis:
ndp->pending_req_num = NCSI_RESERVED_CHANNEL; ndp->pending_req_num = NCSI_RESERVED_CHANNEL;
...@@ -1447,7 +1435,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) ...@@ -1447,7 +1435,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
if (IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY)) if (IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY))
nd->state = ncsi_dev_state_probe_keep_phy; nd->state = ncsi_dev_state_probe_keep_phy;
break; break;
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY)
case ncsi_dev_state_probe_keep_phy: case ncsi_dev_state_probe_keep_phy:
ndp->pending_req_num = 1; ndp->pending_req_num = 1;
...@@ -1460,7 +1447,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) ...@@ -1460,7 +1447,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
nd->state = ncsi_dev_state_probe_gvi; nd->state = ncsi_dev_state_probe_gvi;
break; break;
#endif /* CONFIG_NCSI_OEM_CMD_KEEP_PHY */
case ncsi_dev_state_probe_gvi: case ncsi_dev_state_probe_gvi:
case ncsi_dev_state_probe_gc: case ncsi_dev_state_probe_gc:
case ncsi_dev_state_probe_gls: case ncsi_dev_state_probe_gls:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment