Skip to content

Commit 6ddc760

Browse files
Yuval Mintzdavem330
authored andcommitted
qed*: IOV support spoof-checking
Add support in `ndo_set_vf_spoofchk' for allowing PF control over its VF spoof-checking configuration. Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 733def6 commit 6ddc760

File tree

6 files changed

+112
-0
lines changed

6 files changed

+112
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
381381
p_ramrod->common.tx_switching_en = p_params->tx_switching_flg;
382382
p_cmn->update_tx_switching_en_flg = p_params->update_tx_switching_flg;
383383

384+
p_cmn->anti_spoofing_en = p_params->anti_spoofing_en;
385+
val = p_params->update_anti_spoofing_en_flg;
386+
p_ramrod->common.update_anti_spoofing_en_flg = val;
387+
384388
rc = qed_sp_vport_update_rss(p_hwfn, p_ramrod, p_rss_params);
385389
if (rc) {
386390
/* Return spq entry which is taken in qed_sp_init_request()*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ struct qed_sp_vport_update_params {
149149
u8 update_tx_switching_flg;
150150
u8 tx_switching_flg;
151151
u8 update_approx_mcast_flg;
152+
u8 update_anti_spoofing_en_flg;
153+
u8 anti_spoofing_en;
152154
u8 update_accept_any_vlan_flg;
153155
u8 accept_any_vlan;
154156
unsigned long bins[8];

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

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,39 @@ static void qed_iov_vf_mbx_acquire(struct qed_hwfn *p_hwfn,
12341234
sizeof(struct pfvf_acquire_resp_tlv), vfpf_status);
12351235
}
12361236

1237+
static int __qed_iov_spoofchk_set(struct qed_hwfn *p_hwfn,
1238+
struct qed_vf_info *p_vf, bool val)
1239+
{
1240+
struct qed_sp_vport_update_params params;
1241+
int rc;
1242+
1243+
if (val == p_vf->spoof_chk) {
1244+
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
1245+
"Spoofchk value[%d] is already configured\n", val);
1246+
return 0;
1247+
}
1248+
1249+
memset(&params, 0, sizeof(struct qed_sp_vport_update_params));
1250+
params.opaque_fid = p_vf->opaque_fid;
1251+
params.vport_id = p_vf->vport_id;
1252+
params.update_anti_spoofing_en_flg = 1;
1253+
params.anti_spoofing_en = val;
1254+
1255+
rc = qed_sp_vport_update(p_hwfn, &params, QED_SPQ_MODE_EBLOCK, NULL);
1256+
if (rc) {
1257+
p_vf->spoof_chk = val;
1258+
p_vf->req_spoofchk_val = p_vf->spoof_chk;
1259+
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
1260+
"Spoofchk val[%d] configured\n", val);
1261+
} else {
1262+
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
1263+
"Spoofchk configuration[val:%d] failed for VF[%d]\n",
1264+
val, p_vf->relative_vf_id);
1265+
}
1266+
1267+
return rc;
1268+
}
1269+
12371270
static int qed_iov_reconfigure_unicast_vlan(struct qed_hwfn *p_hwfn,
12381271
struct qed_vf_info *p_vf)
12391272
{
@@ -1476,6 +1509,8 @@ static void qed_iov_vf_mbx_start_vport(struct qed_hwfn *p_hwfn,
14761509

14771510
/* Force configuration if needed on the newly opened vport */
14781511
qed_iov_configure_vport_forced(p_hwfn, vf, *p_bitmap);
1512+
1513+
__qed_iov_spoofchk_set(p_hwfn, vf, vf->req_spoofchk_val);
14791514
}
14801515
qed_iov_prepare_resp(p_hwfn, p_ptt, vf, CHANNEL_TLV_VPORT_START,
14811516
sizeof(struct pfvf_def_resp_tlv), status);
@@ -1489,6 +1524,7 @@ static void qed_iov_vf_mbx_stop_vport(struct qed_hwfn *p_hwfn,
14891524
int rc;
14901525

14911526
vf->vport_instance--;
1527+
vf->spoof_chk = false;
14921528

14931529
rc = qed_sp_vport_stop(p_hwfn, vf->opaque_fid, vf->vport_id);
14941530
if (rc != 0) {
@@ -2782,6 +2818,17 @@ void qed_iov_bulletin_set_forced_vlan(struct qed_hwfn *p_hwfn,
27822818
qed_iov_configure_vport_forced(p_hwfn, vf_info, feature);
27832819
}
27842820

2821+
static bool qed_iov_vf_has_vport_instance(struct qed_hwfn *p_hwfn, int vfid)
2822+
{
2823+
struct qed_vf_info *p_vf_info;
2824+
2825+
p_vf_info = qed_iov_get_vf_info(p_hwfn, (u16) vfid, true);
2826+
if (!p_vf_info)
2827+
return false;
2828+
2829+
return !!p_vf_info->vport_instance;
2830+
}
2831+
27852832
bool qed_iov_is_vf_stopped(struct qed_hwfn *p_hwfn, int vfid)
27862833
{
27872834
struct qed_vf_info *p_vf_info;
@@ -2793,6 +2840,34 @@ bool qed_iov_is_vf_stopped(struct qed_hwfn *p_hwfn, int vfid)
27932840
return p_vf_info->state == VF_STOPPED;
27942841
}
27952842

2843+
int qed_iov_spoofchk_set(struct qed_hwfn *p_hwfn, int vfid, bool val)
2844+
{
2845+
struct qed_vf_info *vf;
2846+
int rc = -EINVAL;
2847+
2848+
if (!qed_iov_pf_sanity_check(p_hwfn, vfid)) {
2849+
DP_NOTICE(p_hwfn,
2850+
"SR-IOV sanity check failed, can't set spoofchk\n");
2851+
goto out;
2852+
}
2853+
2854+
vf = qed_iov_get_vf_info(p_hwfn, (u16) vfid, true);
2855+
if (!vf)
2856+
goto out;
2857+
2858+
if (!qed_iov_vf_has_vport_instance(p_hwfn, vfid)) {
2859+
/* After VF VPORT start PF will configure spoof check */
2860+
vf->req_spoofchk_val = val;
2861+
rc = 0;
2862+
goto out;
2863+
}
2864+
2865+
rc = __qed_iov_spoofchk_set(p_hwfn, vf, val);
2866+
2867+
out:
2868+
return rc;
2869+
}
2870+
27962871
static u8 *qed_iov_bulletin_get_forced_mac(struct qed_hwfn *p_hwfn,
27972872
u16 rel_vf_id)
27982873
{
@@ -3179,6 +3254,21 @@ static int qed_set_vf_link_state(struct qed_dev *cdev,
31793254
return 0;
31803255
}
31813256

3257+
static int qed_spoof_configure(struct qed_dev *cdev, int vfid, bool val)
3258+
{
3259+
int i, rc = -EINVAL;
3260+
3261+
for_each_hwfn(cdev, i) {
3262+
struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
3263+
3264+
rc = qed_iov_spoofchk_set(p_hwfn, vfid, val);
3265+
if (rc)
3266+
break;
3267+
}
3268+
3269+
return rc;
3270+
}
3271+
31823272
static int qed_configure_max_vf_rate(struct qed_dev *cdev, int vfid, int rate)
31833273
{
31843274
int i;
@@ -3417,5 +3507,6 @@ const struct qed_iov_hv_ops qed_iov_ops_pass = {
34173507
.set_mac = &qed_sriov_pf_set_mac,
34183508
.set_vlan = &qed_sriov_pf_set_vlan,
34193509
.set_link_state = &qed_set_vf_link_state,
3510+
.set_spoof = &qed_spoof_configure,
34203511
.set_rate = &qed_set_vf_rate,
34213512
};

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ struct qed_vf_info {
154154
u16 igu_sbs[QED_MAX_VF_CHAINS_PER_PF];
155155
u8 num_active_rxqs;
156156
struct qed_public_vf_info p_vf_info;
157+
bool spoof_chk;
158+
bool req_spoofchk_val;
157159

158160
/* Stores the configuration requested by VF */
159161
struct qed_vf_shadow_config shadow_config;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,16 @@ static int qede_set_vf_rate(struct net_device *dev, int vfidx,
18021802
max_tx_rate);
18031803
}
18041804

1805+
static int qede_set_vf_spoofchk(struct net_device *dev, int vfidx, bool val)
1806+
{
1807+
struct qede_dev *edev = netdev_priv(dev);
1808+
1809+
if (!edev->ops)
1810+
return -EINVAL;
1811+
1812+
return edev->ops->iov->set_spoof(edev->cdev, vfidx, val);
1813+
}
1814+
18051815
static int qede_set_vf_link_state(struct net_device *dev, int vfidx,
18061816
int link_state)
18071817
{
@@ -2142,6 +2152,7 @@ static const struct net_device_ops qede_netdev_ops = {
21422152
.ndo_get_stats64 = qede_get_stats64,
21432153
#ifdef CONFIG_QED_SRIOV
21442154
.ndo_set_vf_link_state = qede_set_vf_link_state,
2155+
.ndo_set_vf_spoofchk = qede_set_vf_spoofchk,
21452156
.ndo_set_vf_rate = qede_set_vf_rate,
21462157
#endif
21472158
#ifdef CONFIG_QEDE_VXLAN

include/linux/qed/qed_iov_if.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ struct qed_iov_hv_ops {
2222
int (*set_link_state) (struct qed_dev *cdev, int vf_id,
2323
int link_state);
2424

25+
int (*set_spoof) (struct qed_dev *cdev, int vfid, bool val);
26+
2527
int (*set_rate) (struct qed_dev *cdev, int vfid,
2628
u32 min_rate, u32 max_rate);
2729
};

0 commit comments

Comments
 (0)