Skip to content

Commit 809c45a

Browse files
Shahed Shaikhdavem330
authored andcommitted
qed* : Add new TLV to request PF to update MAC in bulletin board
There may be a need for VF driver to request PF to explicitly update its bulletin with a MAC address. e.g. When user assigns a MAC address to VF while VF is still down, and PF's bulletin board contains different MAC address, in this case, when VF's interface is brought up, it gets loaded with MAC address from bulletin board which is not desirable. To handle this corner case, we need a new TLV to request PF to update its bulletin board with suggested MAC. This request will be honored only for trusted VFs. Signed-off-by: Shahed Shaikh <shahed.shaikh@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7425d82 commit 809c45a

File tree

6 files changed

+111
-0
lines changed

6 files changed

+111
-0
lines changed

drivers/net/ethernet/qlogic/qed/qed_l2.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,6 +2850,24 @@ static int qed_fp_cqe_completion(struct qed_dev *dev,
28502850
cqe);
28512851
}
28522852

2853+
static int qed_req_bulletin_update_mac(struct qed_dev *cdev, u8 *mac)
2854+
{
2855+
int i, ret;
2856+
2857+
if (IS_PF(cdev))
2858+
return 0;
2859+
2860+
for_each_hwfn(cdev, i) {
2861+
struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
2862+
2863+
ret = qed_vf_pf_bulletin_update_mac(p_hwfn, mac);
2864+
if (ret)
2865+
return ret;
2866+
}
2867+
2868+
return 0;
2869+
}
2870+
28532871
#ifdef CONFIG_QED_SRIOV
28542872
extern const struct qed_iov_hv_ops qed_iov_ops_pass;
28552873
#endif
@@ -2887,6 +2905,7 @@ static const struct qed_eth_ops qed_eth_ops_pass = {
28872905
.ntuple_filter_config = &qed_ntuple_arfs_filter_config,
28882906
.configure_arfs_searcher = &qed_configure_arfs_searcher,
28892907
.get_coalesce = &qed_get_coalesce,
2908+
.req_bulletin_update_mac = &qed_req_bulletin_update_mac,
28902909
};
28912910

28922911
const struct qed_eth_ops *qed_get_eth_ops(void)

drivers/net/ethernet/qlogic/qed/qed_sriov.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3820,6 +3820,40 @@ static void qed_iov_get_link(struct qed_hwfn *p_hwfn,
38203820
__qed_vf_get_link_caps(p_hwfn, p_caps, p_bulletin);
38213821
}
38223822

3823+
static int
3824+
qed_iov_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
3825+
struct qed_ptt *p_ptt,
3826+
struct qed_vf_info *p_vf)
3827+
{
3828+
struct qed_bulletin_content *p_bulletin = p_vf->bulletin.p_virt;
3829+
struct qed_iov_vf_mbx *mbx = &p_vf->vf_mbx;
3830+
struct vfpf_bulletin_update_mac_tlv *p_req;
3831+
u8 status = PFVF_STATUS_SUCCESS;
3832+
int rc = 0;
3833+
3834+
if (!p_vf->p_vf_info.is_trusted_configured) {
3835+
DP_VERBOSE(p_hwfn,
3836+
QED_MSG_IOV,
3837+
"Blocking bulletin update request from untrusted VF[%d]\n",
3838+
p_vf->abs_vf_id);
3839+
status = PFVF_STATUS_NOT_SUPPORTED;
3840+
rc = -EINVAL;
3841+
goto send_status;
3842+
}
3843+
3844+
p_req = &mbx->req_virt->bulletin_update_mac;
3845+
ether_addr_copy(p_bulletin->mac, p_req->mac);
3846+
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
3847+
"Updated bulletin of VF[%d] with requested MAC[%pM]\n",
3848+
p_vf->abs_vf_id, p_req->mac);
3849+
3850+
send_status:
3851+
qed_iov_prepare_resp(p_hwfn, p_ptt, p_vf,
3852+
CHANNEL_TLV_BULLETIN_UPDATE_MAC,
3853+
sizeof(struct pfvf_def_resp_tlv), status);
3854+
return rc;
3855+
}
3856+
38233857
static void qed_iov_process_mbx_req(struct qed_hwfn *p_hwfn,
38243858
struct qed_ptt *p_ptt, int vfid)
38253859
{
@@ -3899,6 +3933,9 @@ static void qed_iov_process_mbx_req(struct qed_hwfn *p_hwfn,
38993933
case CHANNEL_TLV_COALESCE_READ:
39003934
qed_iov_vf_pf_get_coalesce(p_hwfn, p_ptt, p_vf);
39013935
break;
3936+
case CHANNEL_TLV_BULLETIN_UPDATE_MAC:
3937+
qed_iov_vf_pf_bulletin_update_mac(p_hwfn, p_ptt, p_vf);
3938+
break;
39023939
}
39033940
} else if (qed_iov_tlv_supported(mbx->first_tlv.tl.type)) {
39043941
DP_VERBOSE(p_hwfn, QED_MSG_IOV,

drivers/net/ethernet/qlogic/qed/qed_vf.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,35 @@ int qed_vf_pf_get_coalesce(struct qed_hwfn *p_hwfn,
13741374
return rc;
13751375
}
13761376

1377+
int
1378+
qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
1379+
u8 *p_mac)
1380+
{
1381+
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
1382+
struct vfpf_bulletin_update_mac_tlv *p_req;
1383+
struct pfvf_def_resp_tlv *p_resp;
1384+
int rc;
1385+
1386+
if (!p_mac)
1387+
return -EINVAL;
1388+
1389+
/* clear mailbox and prep header tlv */
1390+
p_req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_BULLETIN_UPDATE_MAC,
1391+
sizeof(*p_req));
1392+
ether_addr_copy(p_req->mac, p_mac);
1393+
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
1394+
"Requesting bulletin update for MAC[%pM]\n", p_mac);
1395+
1396+
/* add list termination tlv */
1397+
qed_add_tlv(p_hwfn, &p_iov->offset, CHANNEL_TLV_LIST_END,
1398+
sizeof(struct channel_list_end_tlv));
1399+
1400+
p_resp = &p_iov->pf2vf_reply->default_resp;
1401+
rc = qed_send_msg2pf(p_hwfn, &p_resp->hdr.status, sizeof(*p_resp));
1402+
qed_vf_pf_req_end(p_hwfn, rc);
1403+
return rc;
1404+
}
1405+
13771406
int
13781407
qed_vf_pf_set_coalesce(struct qed_hwfn *p_hwfn,
13791408
u16 rx_coal, u16 tx_coal, struct qed_queue_cid *p_cid)

drivers/net/ethernet/qlogic/qed/qed_vf.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,12 @@ struct pfvf_read_coal_resp_tlv {
518518
u8 padding[6];
519519
};
520520

521+
struct vfpf_bulletin_update_mac_tlv {
522+
struct vfpf_first_tlv first_tlv;
523+
u8 mac[ETH_ALEN];
524+
u8 padding[2];
525+
};
526+
521527
union vfpf_tlvs {
522528
struct vfpf_first_tlv first_tlv;
523529
struct vfpf_acquire_tlv acquire;
@@ -532,6 +538,7 @@ union vfpf_tlvs {
532538
struct vfpf_update_tunn_param_tlv tunn_param_update;
533539
struct vfpf_update_coalesce update_coalesce;
534540
struct vfpf_read_coal_req_tlv read_coal_req;
541+
struct vfpf_bulletin_update_mac_tlv bulletin_update_mac;
535542
struct tlv_buffer_size tlv_buf_size;
536543
};
537544

@@ -650,6 +657,7 @@ enum {
650657
CHANNEL_TLV_COALESCE_UPDATE,
651658
CHANNEL_TLV_QID,
652659
CHANNEL_TLV_COALESCE_READ,
660+
CHANNEL_TLV_BULLETIN_UPDATE_MAC,
653661
CHANNEL_TLV_MAX,
654662

655663
/* Required for iterating over vport-update tlvs.
@@ -1042,6 +1050,13 @@ int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
10421050
struct qed_tunnel_info *p_tunn);
10431051

10441052
u32 qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn, enum BAR_ID bar_id);
1053+
/**
1054+
* @brief - Ask PF to update the MAC address in it's bulletin board
1055+
*
1056+
* @param p_mac - mac address to be updated in bulletin board
1057+
*/
1058+
int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn, u8 *p_mac);
1059+
10451060
#else
10461061
static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
10471062
struct qed_mcp_link_params *params)
@@ -1228,6 +1243,12 @@ static inline int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
12281243
return -EINVAL;
12291244
}
12301245

1246+
static inline int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
1247+
u8 *p_mac)
1248+
{
1249+
return -EINVAL;
1250+
}
1251+
12311252
static inline u32
12321253
qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn,
12331254
enum BAR_ID bar_id)

drivers/net/ethernet/qlogic/qede/qede_filter.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,10 @@ int qede_set_mac_addr(struct net_device *ndev, void *p)
11601160
if (edev->state != QEDE_STATE_OPEN) {
11611161
DP_VERBOSE(edev, NETIF_MSG_IFDOWN,
11621162
"The device is currently down\n");
1163+
/* Ask PF to explicitly update a copy in bulletin board */
1164+
if (IS_VF(edev) && edev->ops->req_bulletin_update_mac)
1165+
edev->ops->req_bulletin_update_mac(edev->cdev,
1166+
ndev->dev_addr);
11631167
goto out;
11641168
}
11651169

include/linux/qed/qed_eth_if.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ struct qed_eth_ops {
352352
int (*configure_arfs_searcher)(struct qed_dev *cdev,
353353
enum qed_filter_config_mode mode);
354354
int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle);
355+
int (*req_bulletin_update_mac)(struct qed_dev *cdev, u8 *mac);
355356
};
356357

357358
const struct qed_eth_ops *qed_get_eth_ops(void);

0 commit comments

Comments
 (0)