Commit a155a5db authored by Sriharsha Basavapatna's avatar Sriharsha Basavapatna Committed by David S. Miller

be2net: support ndo_get_phys_port_id()

Add be_get_phys_port_id() function to report physical port id. The port id
should be unique across different be2net devices in the system. We use the
chip serial number along with the physical port number for this.
Signed-off-by: default avatarSriharsha Basavapatna <sriharsha.basavapatna@avagotech.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 045a0fa0
...@@ -105,6 +105,8 @@ ...@@ -105,6 +105,8 @@
#define MAX_VFS 30 /* Max VFs supported by BE3 FW */ #define MAX_VFS 30 /* Max VFs supported by BE3 FW */
#define FW_VER_LEN 32 #define FW_VER_LEN 32
#define CNTL_SERIAL_NUM_WORDS 8 /* Controller serial number words */
#define CNTL_SERIAL_NUM_WORD_SZ (sizeof(u16)) /* Byte-sz of serial num word */
#define RSS_INDIR_TABLE_LEN 128 #define RSS_INDIR_TABLE_LEN 128
#define RSS_HASH_KEY_LEN 40 #define RSS_HASH_KEY_LEN 40
...@@ -590,6 +592,7 @@ struct be_adapter { ...@@ -590,6 +592,7 @@ struct be_adapter {
struct rss_info rss_info; struct rss_info rss_info;
/* Filters for packets that need to be sent to BMC */ /* Filters for packets that need to be sent to BMC */
u32 bmc_filt_mask; u32 bmc_filt_mask;
u16 serial_num[CNTL_SERIAL_NUM_WORDS];
}; };
#define be_physfn(adapter) (!adapter->virtfn) #define be_physfn(adapter) (!adapter->virtfn)
......
...@@ -2852,10 +2852,11 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter) ...@@ -2852,10 +2852,11 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
struct be_mcc_wrb *wrb; struct be_mcc_wrb *wrb;
struct be_cmd_req_cntl_attribs *req; struct be_cmd_req_cntl_attribs *req;
struct be_cmd_resp_cntl_attribs *resp; struct be_cmd_resp_cntl_attribs *resp;
int status; int status, i;
int payload_len = max(sizeof(*req), sizeof(*resp)); int payload_len = max(sizeof(*req), sizeof(*resp));
struct mgmt_controller_attrib *attribs; struct mgmt_controller_attrib *attribs;
struct be_dma_mem attribs_cmd; struct be_dma_mem attribs_cmd;
u32 *serial_num;
if (mutex_lock_interruptible(&adapter->mbox_lock)) if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1; return -1;
...@@ -2886,6 +2887,10 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter) ...@@ -2886,6 +2887,10 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
if (!status) { if (!status) {
attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr); attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr);
adapter->hba_port_num = attribs->hba_attribs.phy_port; adapter->hba_port_num = attribs->hba_attribs.phy_port;
serial_num = attribs->hba_attribs.controller_serial_number;
for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++)
adapter->serial_num[i] = le32_to_cpu(serial_num[i]) &
(BIT_MASK(16) - 1);
} }
err: err:
......
...@@ -1637,10 +1637,12 @@ struct be_cmd_req_set_qos { ...@@ -1637,10 +1637,12 @@ struct be_cmd_req_set_qos {
struct mgmt_hba_attribs { struct mgmt_hba_attribs {
u32 rsvd0[24]; u32 rsvd0[24];
u8 controller_model_number[32]; u8 controller_model_number[32];
u32 rsvd1[79]; u32 rsvd1[16];
u8 rsvd2[3]; u32 controller_serial_number[8];
u32 rsvd2[55];
u8 rsvd3[3];
u8 phy_port; u8 phy_port;
u32 rsvd3[13]; u32 rsvd4[13];
} __packed; } __packed;
struct mgmt_controller_attrib { struct mgmt_controller_attrib {
......
...@@ -5219,6 +5219,27 @@ static netdev_features_t be_features_check(struct sk_buff *skb, ...@@ -5219,6 +5219,27 @@ static netdev_features_t be_features_check(struct sk_buff *skb,
} }
#endif #endif
static int be_get_phys_port_id(struct net_device *dev,
struct netdev_phys_item_id *ppid)
{
int i, id_len = CNTL_SERIAL_NUM_WORDS * CNTL_SERIAL_NUM_WORD_SZ + 1;
struct be_adapter *adapter = netdev_priv(dev);
u8 *id;
if (MAX_PHYS_ITEM_ID_LEN < id_len)
return -ENOSPC;
ppid->id[0] = adapter->hba_port_num + 1;
id = &ppid->id[1];
for (i = CNTL_SERIAL_NUM_WORDS - 1; i >= 0;
i--, id += CNTL_SERIAL_NUM_WORD_SZ)
memcpy(id, &adapter->serial_num[i], CNTL_SERIAL_NUM_WORD_SZ);
ppid->id_len = id_len;
return 0;
}
static const struct net_device_ops be_netdev_ops = { static const struct net_device_ops be_netdev_ops = {
.ndo_open = be_open, .ndo_open = be_open,
.ndo_stop = be_close, .ndo_stop = be_close,
...@@ -5249,6 +5270,7 @@ static const struct net_device_ops be_netdev_ops = { ...@@ -5249,6 +5270,7 @@ static const struct net_device_ops be_netdev_ops = {
.ndo_del_vxlan_port = be_del_vxlan_port, .ndo_del_vxlan_port = be_del_vxlan_port,
.ndo_features_check = be_features_check, .ndo_features_check = be_features_check,
#endif #endif
.ndo_get_phys_port_id = be_get_phys_port_id,
}; };
static void be_netdev_init(struct net_device *netdev) static void be_netdev_init(struct net_device *netdev)
......
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