Commit 4dce97b1 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'ncsi-mac-address-command'

Patrick Williams says:

====================
net/ncsi: Add NC-SI 1.2 Get MC MAC Address command

NC-SI 1.2 has now been published[1] and adds a new command for "Get MC
MAC Address".  This is often used by BMCs to get the assigned MAC
address for the channel used by the BMC.

This change set has been tested on a Broadcomm 200G NIC with updated
firmware for NC-SI 1.2 and at least one other non-public NIC design.

1. https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.2.0.pdf


====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f9672265 b8291cf3
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -105,8 +105,11 @@ enum {


struct ncsi_channel_version {
	u32 version;		/* Supported BCD encoded NCSI version */
	u32 alpha2;		/* Supported BCD encoded NCSI version */
	u8   major;		/* NCSI version major */
	u8   minor;		/* NCSI version minor */
	u8   update;		/* NCSI version update */
	char alpha1;		/* NCSI version alpha1 */
	char alpha2;		/* NCSI version alpha2 */
	u8  fw_name[12];	/* Firmware name string                */
	u32 fw_version;		/* Firmware version                   */
	u16 pci_ids[4];		/* PCI identification                 */
+2 −1
Original line number Diff line number Diff line
@@ -270,7 +270,8 @@ static struct ncsi_cmd_handler {
	{ NCSI_PKT_CMD_GPS,    0, ncsi_cmd_handler_default },
	{ NCSI_PKT_CMD_OEM,   -1, ncsi_cmd_handler_oem     },
	{ NCSI_PKT_CMD_PLDM,   0, NULL                     },
	{ NCSI_PKT_CMD_GPUUID, 0, ncsi_cmd_handler_default }
	{ NCSI_PKT_CMD_GPUUID, 0, ncsi_cmd_handler_default },
	{ NCSI_PKT_CMD_GMCMA,  0, ncsi_cmd_handler_default }
};

static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca)
+10 −19
Original line number Diff line number Diff line
@@ -689,8 +689,6 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc,
	return 0;
}

#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY)

static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca)
{
	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)
	return ret;
}

#endif

#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC)

/* NCSI OEM Command APIs */
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)
	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 */
static bool ncsi_channel_is_tx(struct ncsi_dev_priv *ndp,
			       struct ncsi_channel *nc)
@@ -1039,20 +1031,23 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
			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;
	case ncsi_dev_state_config_oem_gma:
		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.package = np->id;
		nca.channel = nc->id;
		ndp->pending_req_num = 1;
		if (nc->version.major >= 1 && nc->version.minor >= 2) {
			nca.type = NCSI_PKT_CMD_GMCMA;
			ret = ncsi_xmit_cmd(&nca);
		} else {
			nca.type = NCSI_PKT_CMD_OEM;
			ret = ncsi_gma_handler(&nca, nc->version.mf_id);
#endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */

		}
		if (ret < 0)
			schedule_work(&ndp->work);

@@ -1404,7 +1399,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)

		schedule_work(&ndp->work);
		break;
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC)
	case ncsi_dev_state_probe_mlx_gma:
		ndp->pending_req_num = 1;

@@ -1429,7 +1423,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)

		nd->state = ncsi_dev_state_probe_cis;
		break;
#endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */
	case ncsi_dev_state_probe_cis:
		ndp->pending_req_num = NCSI_RESERVED_CHANNEL;

@@ -1447,7 +1440,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
		if (IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY))
			nd->state = ncsi_dev_state_probe_keep_phy;
		break;
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY)
	case ncsi_dev_state_probe_keep_phy:
		ndp->pending_req_num = 1;

@@ -1460,7 +1452,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)

		nd->state = ncsi_dev_state_probe_gvi;
		break;
#endif /* CONFIG_NCSI_OEM_CMD_KEEP_PHY */
	case ncsi_dev_state_probe_gvi:
	case ncsi_dev_state_probe_gc:
	case ncsi_dev_state_probe_gls:
+2 −2
Original line number Diff line number Diff line
@@ -71,8 +71,8 @@ static int ncsi_write_channel_info(struct sk_buff *skb,
	if (nc == nc->package->preferred_channel)
		nla_put_flag(skb, NCSI_CHANNEL_ATTR_FORCED);

	nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MAJOR, nc->version.version);
	nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MINOR, nc->version.alpha2);
	nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MAJOR, nc->version.major);
	nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MINOR, nc->version.minor);
	nla_put_string(skb, NCSI_CHANNEL_ATTR_VERSION_STR, nc->version.fw_name);

	vid_nest = nla_nest_start_noflag(skb, NCSI_CHANNEL_ATTR_VLAN_LIST);
+15 −2
Original line number Diff line number Diff line
@@ -197,9 +197,12 @@ struct ncsi_rsp_gls_pkt {
/* Get Version ID */
struct ncsi_rsp_gvi_pkt {
	struct ncsi_rsp_pkt_hdr rsp;          /* Response header */
	__be32                  ncsi_version; /* NCSI version    */
	unsigned char           major;        /* NCSI version major */
	unsigned char           minor;        /* NCSI version minor */
	unsigned char           update;       /* NCSI version update */
	unsigned char           alpha1;       /* NCSI version alpha1 */
	unsigned char           reserved[3];  /* Reserved        */
	unsigned char           alpha2;       /* NCSI version    */
	unsigned char           alpha2;       /* NCSI version alpha2 */
	unsigned char           fw_name[12];  /* f/w name string */
	__be32                  fw_version;   /* f/w version     */
	__be16                  pci_ids[4];   /* PCI IDs         */
@@ -335,6 +338,14 @@ struct ncsi_rsp_gpuuid_pkt {
	__be32                  checksum;
};

/* Get MC MAC Address */
struct ncsi_rsp_gmcma_pkt {
	struct ncsi_rsp_pkt_hdr rsp;
	unsigned char           address_count;
	unsigned char           reserved[3];
	unsigned char           addresses[][ETH_ALEN];
};

/* AEN: Link State Change */
struct ncsi_aen_lsc_pkt {
	struct ncsi_aen_pkt_hdr aen;        /* AEN header      */
@@ -395,6 +406,7 @@ struct ncsi_aen_hncdsc_pkt {
#define NCSI_PKT_CMD_GPUUID	0x52 /* Get package UUID                 */
#define NCSI_PKT_CMD_QPNPR	0x56 /* Query Pending NC PLDM request */
#define NCSI_PKT_CMD_SNPR	0x57 /* Send NC PLDM Reply  */
#define NCSI_PKT_CMD_GMCMA	0x58 /* Get MC MAC Address */


/* NCSI packet responses */
@@ -430,6 +442,7 @@ struct ncsi_aen_hncdsc_pkt {
#define NCSI_PKT_RSP_GPUUID	(NCSI_PKT_CMD_GPUUID + 0x80)
#define NCSI_PKT_RSP_QPNPR	(NCSI_PKT_CMD_QPNPR   + 0x80)
#define NCSI_PKT_RSP_SNPR	(NCSI_PKT_CMD_SNPR   + 0x80)
#define NCSI_PKT_RSP_GMCMA	(NCSI_PKT_CMD_GMCMA  + 0x80)

/* NCSI response code/reason */
#define NCSI_PKT_RSP_C_COMPLETED	0x0000 /* Command Completed        */
Loading