Commit 809c45a0 authored by Shahed Shaikh's avatar Shahed Shaikh Committed by David S. Miller

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: default avatarShahed Shaikh <shahed.shaikh@cavium.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7425d822
......@@ -2850,6 +2850,24 @@ static int qed_fp_cqe_completion(struct qed_dev *dev,
cqe);
}
static int qed_req_bulletin_update_mac(struct qed_dev *cdev, u8 *mac)
{
int i, ret;
if (IS_PF(cdev))
return 0;
for_each_hwfn(cdev, i) {
struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
ret = qed_vf_pf_bulletin_update_mac(p_hwfn, mac);
if (ret)
return ret;
}
return 0;
}
#ifdef CONFIG_QED_SRIOV
extern const struct qed_iov_hv_ops qed_iov_ops_pass;
#endif
......@@ -2887,6 +2905,7 @@ static const struct qed_eth_ops qed_eth_ops_pass = {
.ntuple_filter_config = &qed_ntuple_arfs_filter_config,
.configure_arfs_searcher = &qed_configure_arfs_searcher,
.get_coalesce = &qed_get_coalesce,
.req_bulletin_update_mac = &qed_req_bulletin_update_mac,
};
const struct qed_eth_ops *qed_get_eth_ops(void)
......
......@@ -3820,6 +3820,40 @@ static void qed_iov_get_link(struct qed_hwfn *p_hwfn,
__qed_vf_get_link_caps(p_hwfn, p_caps, p_bulletin);
}
static int
qed_iov_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
struct qed_ptt *p_ptt,
struct qed_vf_info *p_vf)
{
struct qed_bulletin_content *p_bulletin = p_vf->bulletin.p_virt;
struct qed_iov_vf_mbx *mbx = &p_vf->vf_mbx;
struct vfpf_bulletin_update_mac_tlv *p_req;
u8 status = PFVF_STATUS_SUCCESS;
int rc = 0;
if (!p_vf->p_vf_info.is_trusted_configured) {
DP_VERBOSE(p_hwfn,
QED_MSG_IOV,
"Blocking bulletin update request from untrusted VF[%d]\n",
p_vf->abs_vf_id);
status = PFVF_STATUS_NOT_SUPPORTED;
rc = -EINVAL;
goto send_status;
}
p_req = &mbx->req_virt->bulletin_update_mac;
ether_addr_copy(p_bulletin->mac, p_req->mac);
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"Updated bulletin of VF[%d] with requested MAC[%pM]\n",
p_vf->abs_vf_id, p_req->mac);
send_status:
qed_iov_prepare_resp(p_hwfn, p_ptt, p_vf,
CHANNEL_TLV_BULLETIN_UPDATE_MAC,
sizeof(struct pfvf_def_resp_tlv), status);
return rc;
}
static void qed_iov_process_mbx_req(struct qed_hwfn *p_hwfn,
struct qed_ptt *p_ptt, int vfid)
{
......@@ -3899,6 +3933,9 @@ static void qed_iov_process_mbx_req(struct qed_hwfn *p_hwfn,
case CHANNEL_TLV_COALESCE_READ:
qed_iov_vf_pf_get_coalesce(p_hwfn, p_ptt, p_vf);
break;
case CHANNEL_TLV_BULLETIN_UPDATE_MAC:
qed_iov_vf_pf_bulletin_update_mac(p_hwfn, p_ptt, p_vf);
break;
}
} else if (qed_iov_tlv_supported(mbx->first_tlv.tl.type)) {
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
......
......@@ -1374,6 +1374,35 @@ int qed_vf_pf_get_coalesce(struct qed_hwfn *p_hwfn,
return rc;
}
int
qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
u8 *p_mac)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct vfpf_bulletin_update_mac_tlv *p_req;
struct pfvf_def_resp_tlv *p_resp;
int rc;
if (!p_mac)
return -EINVAL;
/* clear mailbox and prep header tlv */
p_req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_BULLETIN_UPDATE_MAC,
sizeof(*p_req));
ether_addr_copy(p_req->mac, p_mac);
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"Requesting bulletin update for MAC[%pM]\n", p_mac);
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset, CHANNEL_TLV_LIST_END,
sizeof(struct channel_list_end_tlv));
p_resp = &p_iov->pf2vf_reply->default_resp;
rc = qed_send_msg2pf(p_hwfn, &p_resp->hdr.status, sizeof(*p_resp));
qed_vf_pf_req_end(p_hwfn, rc);
return rc;
}
int
qed_vf_pf_set_coalesce(struct qed_hwfn *p_hwfn,
u16 rx_coal, u16 tx_coal, struct qed_queue_cid *p_cid)
......
......@@ -518,6 +518,12 @@ struct pfvf_read_coal_resp_tlv {
u8 padding[6];
};
struct vfpf_bulletin_update_mac_tlv {
struct vfpf_first_tlv first_tlv;
u8 mac[ETH_ALEN];
u8 padding[2];
};
union vfpf_tlvs {
struct vfpf_first_tlv first_tlv;
struct vfpf_acquire_tlv acquire;
......@@ -532,6 +538,7 @@ union vfpf_tlvs {
struct vfpf_update_tunn_param_tlv tunn_param_update;
struct vfpf_update_coalesce update_coalesce;
struct vfpf_read_coal_req_tlv read_coal_req;
struct vfpf_bulletin_update_mac_tlv bulletin_update_mac;
struct tlv_buffer_size tlv_buf_size;
};
......@@ -650,6 +657,7 @@ enum {
CHANNEL_TLV_COALESCE_UPDATE,
CHANNEL_TLV_QID,
CHANNEL_TLV_COALESCE_READ,
CHANNEL_TLV_BULLETIN_UPDATE_MAC,
CHANNEL_TLV_MAX,
/* Required for iterating over vport-update tlvs.
......@@ -1042,6 +1050,13 @@ int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
struct qed_tunnel_info *p_tunn);
u32 qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn, enum BAR_ID bar_id);
/**
* @brief - Ask PF to update the MAC address in it's bulletin board
*
* @param p_mac - mac address to be updated in bulletin board
*/
int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn, u8 *p_mac);
#else
static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
struct qed_mcp_link_params *params)
......@@ -1228,6 +1243,12 @@ static inline int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
return -EINVAL;
}
static inline int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
u8 *p_mac)
{
return -EINVAL;
}
static inline u32
qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn,
enum BAR_ID bar_id)
......
......@@ -1160,6 +1160,10 @@ int qede_set_mac_addr(struct net_device *ndev, void *p)
if (edev->state != QEDE_STATE_OPEN) {
DP_VERBOSE(edev, NETIF_MSG_IFDOWN,
"The device is currently down\n");
/* Ask PF to explicitly update a copy in bulletin board */
if (IS_VF(edev) && edev->ops->req_bulletin_update_mac)
edev->ops->req_bulletin_update_mac(edev->cdev,
ndev->dev_addr);
goto out;
}
......
......@@ -352,6 +352,7 @@ struct qed_eth_ops {
int (*configure_arfs_searcher)(struct qed_dev *cdev,
enum qed_filter_config_mode mode);
int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle);
int (*req_bulletin_update_mac)(struct qed_dev *cdev, u8 *mac);
};
const struct qed_eth_ops *qed_get_eth_ops(void);
......
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