Skip to content

Commit a155a5d

Browse files
Sriharsha Basavapatnadavem330
authored andcommitted
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: Sriharsha Basavapatna <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 045a0fa commit a155a5d

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

drivers/net/ethernet/emulex/benet/be.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@
105105

106106
#define MAX_VFS 30 /* Max VFs supported by BE3 FW */
107107
#define FW_VER_LEN 32
108+
#define CNTL_SERIAL_NUM_WORDS 8 /* Controller serial number words */
109+
#define CNTL_SERIAL_NUM_WORD_SZ (sizeof(u16)) /* Byte-sz of serial num word */
108110

109111
#define RSS_INDIR_TABLE_LEN 128
110112
#define RSS_HASH_KEY_LEN 40
@@ -590,6 +592,7 @@ struct be_adapter {
590592
struct rss_info rss_info;
591593
/* Filters for packets that need to be sent to BMC */
592594
u32 bmc_filt_mask;
595+
u16 serial_num[CNTL_SERIAL_NUM_WORDS];
593596
};
594597

595598
#define be_physfn(adapter) (!adapter->virtfn)

drivers/net/ethernet/emulex/benet/be_cmds.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2852,10 +2852,11 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
28522852
struct be_mcc_wrb *wrb;
28532853
struct be_cmd_req_cntl_attribs *req;
28542854
struct be_cmd_resp_cntl_attribs *resp;
2855-
int status;
2855+
int status, i;
28562856
int payload_len = max(sizeof(*req), sizeof(*resp));
28572857
struct mgmt_controller_attrib *attribs;
28582858
struct be_dma_mem attribs_cmd;
2859+
u32 *serial_num;
28592860

28602861
if (mutex_lock_interruptible(&adapter->mbox_lock))
28612862
return -1;
@@ -2886,6 +2887,10 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
28862887
if (!status) {
28872888
attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr);
28882889
adapter->hba_port_num = attribs->hba_attribs.phy_port;
2890+
serial_num = attribs->hba_attribs.controller_serial_number;
2891+
for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++)
2892+
adapter->serial_num[i] = le32_to_cpu(serial_num[i]) &
2893+
(BIT_MASK(16) - 1);
28892894
}
28902895

28912896
err:

drivers/net/ethernet/emulex/benet/be_cmds.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,10 +1637,12 @@ struct be_cmd_req_set_qos {
16371637
struct mgmt_hba_attribs {
16381638
u32 rsvd0[24];
16391639
u8 controller_model_number[32];
1640-
u32 rsvd1[79];
1641-
u8 rsvd2[3];
1640+
u32 rsvd1[16];
1641+
u32 controller_serial_number[8];
1642+
u32 rsvd2[55];
1643+
u8 rsvd3[3];
16421644
u8 phy_port;
1643-
u32 rsvd3[13];
1645+
u32 rsvd4[13];
16441646
} __packed;
16451647

16461648
struct mgmt_controller_attrib {

drivers/net/ethernet/emulex/benet/be_main.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5219,6 +5219,27 @@ static netdev_features_t be_features_check(struct sk_buff *skb,
52195219
}
52205220
#endif
52215221

5222+
static int be_get_phys_port_id(struct net_device *dev,
5223+
struct netdev_phys_item_id *ppid)
5224+
{
5225+
int i, id_len = CNTL_SERIAL_NUM_WORDS * CNTL_SERIAL_NUM_WORD_SZ + 1;
5226+
struct be_adapter *adapter = netdev_priv(dev);
5227+
u8 *id;
5228+
5229+
if (MAX_PHYS_ITEM_ID_LEN < id_len)
5230+
return -ENOSPC;
5231+
5232+
ppid->id[0] = adapter->hba_port_num + 1;
5233+
id = &ppid->id[1];
5234+
for (i = CNTL_SERIAL_NUM_WORDS - 1; i >= 0;
5235+
i--, id += CNTL_SERIAL_NUM_WORD_SZ)
5236+
memcpy(id, &adapter->serial_num[i], CNTL_SERIAL_NUM_WORD_SZ);
5237+
5238+
ppid->id_len = id_len;
5239+
5240+
return 0;
5241+
}
5242+
52225243
static const struct net_device_ops be_netdev_ops = {
52235244
.ndo_open = be_open,
52245245
.ndo_stop = be_close,
@@ -5249,6 +5270,7 @@ static const struct net_device_ops be_netdev_ops = {
52495270
.ndo_del_vxlan_port = be_del_vxlan_port,
52505271
.ndo_features_check = be_features_check,
52515272
#endif
5273+
.ndo_get_phys_port_id = be_get_phys_port_id,
52525274
};
52535275

52545276
static void be_netdev_init(struct net_device *netdev)

0 commit comments

Comments
 (0)