Skip to content

Commit 73390ac

Browse files
Yuval Mintzdavem330
authored andcommitted
qed*: support ndo_get_vf_config
Allows the user to view the VF configuration by observing the PF's device. Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6ddc760 commit 73390ac

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

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

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,30 @@ void qed_iov_set_link(struct qed_hwfn *p_hwfn,
25882588
p_bulletin->capability_speed = p_caps->speed_capabilities;
25892589
}
25902590

2591+
static void qed_iov_get_link(struct qed_hwfn *p_hwfn,
2592+
u16 vfid,
2593+
struct qed_mcp_link_params *p_params,
2594+
struct qed_mcp_link_state *p_link,
2595+
struct qed_mcp_link_capabilities *p_caps)
2596+
{
2597+
struct qed_vf_info *p_vf = qed_iov_get_vf_info(p_hwfn,
2598+
vfid,
2599+
false);
2600+
struct qed_bulletin_content *p_bulletin;
2601+
2602+
if (!p_vf)
2603+
return;
2604+
2605+
p_bulletin = p_vf->bulletin.p_virt;
2606+
2607+
if (p_params)
2608+
__qed_vf_get_link_params(p_hwfn, p_params, p_bulletin);
2609+
if (p_link)
2610+
__qed_vf_get_link_state(p_hwfn, p_link, p_bulletin);
2611+
if (p_caps)
2612+
__qed_vf_get_link_caps(p_hwfn, p_caps, p_bulletin);
2613+
}
2614+
25912615
static void qed_iov_process_mbx_req(struct qed_hwfn *p_hwfn,
25922616
struct qed_ptt *p_ptt, int vfid)
25932617
{
@@ -2840,6 +2864,17 @@ bool qed_iov_is_vf_stopped(struct qed_hwfn *p_hwfn, int vfid)
28402864
return p_vf_info->state == VF_STOPPED;
28412865
}
28422866

2867+
static bool qed_iov_spoofchk_get(struct qed_hwfn *p_hwfn, int vfid)
2868+
{
2869+
struct qed_vf_info *vf_info;
2870+
2871+
vf_info = qed_iov_get_vf_info(p_hwfn, (u16) vfid, true);
2872+
if (!vf_info)
2873+
return false;
2874+
2875+
return vf_info->spoof_chk;
2876+
}
2877+
28432878
int qed_iov_spoofchk_set(struct qed_hwfn *p_hwfn, int vfid, bool val)
28442879
{
28452880
struct qed_vf_info *vf;
@@ -2937,6 +2972,23 @@ int qed_iov_configure_min_tx_rate(struct qed_dev *cdev, int vfid, u32 rate)
29372972
return qed_configure_vport_wfq(cdev, vport_id, rate);
29382973
}
29392974

2975+
static int qed_iov_get_vf_min_rate(struct qed_hwfn *p_hwfn, int vfid)
2976+
{
2977+
struct qed_wfq_data *vf_vp_wfq;
2978+
struct qed_vf_info *vf_info;
2979+
2980+
vf_info = qed_iov_get_vf_info(p_hwfn, (u16) vfid, true);
2981+
if (!vf_info)
2982+
return 0;
2983+
2984+
vf_vp_wfq = &p_hwfn->qm_info.wfq_data[vf_info->vport_id];
2985+
2986+
if (vf_vp_wfq->configured)
2987+
return vf_vp_wfq->min_speed;
2988+
else
2989+
return 0;
2990+
}
2991+
29402992
/**
29412993
* qed_schedule_iov - schedules IOV task for VF and PF
29422994
* @hwfn: hardware function pointer
@@ -3153,6 +3205,46 @@ static int qed_sriov_pf_set_vlan(struct qed_dev *cdev, u16 vid, int vfid)
31533205
return 0;
31543206
}
31553207

3208+
static int qed_get_vf_config(struct qed_dev *cdev,
3209+
int vf_id, struct ifla_vf_info *ivi)
3210+
{
3211+
struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
3212+
struct qed_public_vf_info *vf_info;
3213+
struct qed_mcp_link_state link;
3214+
u32 tx_rate;
3215+
3216+
/* Sanitize request */
3217+
if (IS_VF(cdev))
3218+
return -EINVAL;
3219+
3220+
if (!qed_iov_is_valid_vfid(&cdev->hwfns[0], vf_id, true)) {
3221+
DP_VERBOSE(cdev, QED_MSG_IOV,
3222+
"VF index [%d] isn't active\n", vf_id);
3223+
return -EINVAL;
3224+
}
3225+
3226+
vf_info = qed_iov_get_public_vf_info(hwfn, vf_id, true);
3227+
3228+
qed_iov_get_link(hwfn, vf_id, NULL, &link, NULL);
3229+
3230+
/* Fill information about VF */
3231+
ivi->vf = vf_id;
3232+
3233+
if (is_valid_ether_addr(vf_info->forced_mac))
3234+
ether_addr_copy(ivi->mac, vf_info->forced_mac);
3235+
else
3236+
ether_addr_copy(ivi->mac, vf_info->mac);
3237+
3238+
ivi->vlan = vf_info->forced_vlan;
3239+
ivi->spoofchk = qed_iov_spoofchk_get(hwfn, vf_id);
3240+
ivi->linkstate = vf_info->link_state;
3241+
tx_rate = vf_info->tx_rate;
3242+
ivi->max_tx_rate = tx_rate ? tx_rate : link.speed;
3243+
ivi->min_tx_rate = qed_iov_get_vf_min_rate(hwfn, vf_id);
3244+
3245+
return 0;
3246+
}
3247+
31563248
void qed_inform_vf_link_state(struct qed_hwfn *hwfn)
31573249
{
31583250
struct qed_mcp_link_capabilities caps;
@@ -3506,6 +3598,7 @@ const struct qed_iov_hv_ops qed_iov_ops_pass = {
35063598
.configure = &qed_sriov_configure,
35073599
.set_mac = &qed_sriov_pf_set_mac,
35083600
.set_vlan = &qed_sriov_pf_set_vlan,
3601+
.get_config = &qed_get_vf_config,
35093602
.set_link_state = &qed_set_vf_link_state,
35103603
.set_spoof = &qed_spoof_configure,
35113604
.set_rate = &qed_set_vf_rate,

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,17 @@ static struct rtnl_link_stats64 *qede_get_stats64(
17931793
}
17941794

17951795
#ifdef CONFIG_QED_SRIOV
1796+
static int qede_get_vf_config(struct net_device *dev, int vfidx,
1797+
struct ifla_vf_info *ivi)
1798+
{
1799+
struct qede_dev *edev = netdev_priv(dev);
1800+
1801+
if (!edev->ops)
1802+
return -EINVAL;
1803+
1804+
return edev->ops->iov->get_config(edev->cdev, vfidx, ivi);
1805+
}
1806+
17961807
static int qede_set_vf_rate(struct net_device *dev, int vfidx,
17971808
int min_tx_rate, int max_tx_rate)
17981809
{
@@ -2153,6 +2164,7 @@ static const struct net_device_ops qede_netdev_ops = {
21532164
#ifdef CONFIG_QED_SRIOV
21542165
.ndo_set_vf_link_state = qede_set_vf_link_state,
21552166
.ndo_set_vf_spoofchk = qede_set_vf_spoofchk,
2167+
.ndo_get_vf_config = qede_get_vf_config,
21562168
.ndo_set_vf_rate = qede_set_vf_rate,
21572169
#endif
21582170
#ifdef CONFIG_QEDE_VXLAN

include/linux/qed/qed_iov_if.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ struct qed_iov_hv_ops {
1919

2020
int (*set_vlan) (struct qed_dev *cdev, u16 vid, int vfid);
2121

22+
int (*get_config) (struct qed_dev *cdev, int vf_id,
23+
struct ifla_vf_info *ivi);
24+
2225
int (*set_link_state) (struct qed_dev *cdev, int vf_id,
2326
int link_state);
2427

0 commit comments

Comments
 (0)