Skip to content

Commit 54011e4

Browse files
h-shimamotoJeff Kirsher
authored andcommitted
ixgbe: Add new ndo to trust VF
Implements the new netdev op to trust VF in ixgbe. The administrator can turn on and off VF trusted by ip command which supports trust message. # ip link set dev eth0 vf 1 trust on or # ip link set dev eth0 vf 1 trust off Send a ping to reset VF on changing the status of trusting. VF driver will reconfigure its features on reset. Signed-off-by: Hiroshi Shimamoto <[email protected]> Tested-by: Krishneil Singh <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent dd461d6 commit 54011e4

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ struct vf_data_storage {
152152
u16 vlan_count;
153153
u8 spoofchk_enabled;
154154
bool rss_query_enabled;
155+
u8 trusted;
155156
unsigned int vf_api;
156157
};
157158

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8407,6 +8407,7 @@ static const struct net_device_ops ixgbe_netdev_ops = {
84078407
.ndo_set_vf_rate = ixgbe_ndo_set_vf_bw,
84088408
.ndo_set_vf_spoofchk = ixgbe_ndo_set_vf_spoofchk,
84098409
.ndo_set_vf_rss_query_en = ixgbe_ndo_set_vf_rss_query_en,
8410+
.ndo_set_vf_trust = ixgbe_ndo_set_vf_trust,
84108411
.ndo_get_vf_config = ixgbe_ndo_get_vf_config,
84118412
.ndo_get_stats64 = ixgbe_get_stats64,
84128413
#ifdef CONFIG_IXGBE_DCB

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
116116
* we want to disable the querying by default.
117117
*/
118118
adapter->vfinfo[i].rss_query_enabled = 0;
119+
120+
/* Untrust all VFs */
121+
adapter->vfinfo[i].trusted = false;
119122
}
120123

121124
return 0;
@@ -1124,6 +1127,17 @@ void ixgbe_disable_tx_rx(struct ixgbe_adapter *adapter)
11241127
IXGBE_WRITE_REG(hw, IXGBE_VFRE(1), 0);
11251128
}
11261129

1130+
static inline void ixgbe_ping_vf(struct ixgbe_adapter *adapter, int vf)
1131+
{
1132+
struct ixgbe_hw *hw = &adapter->hw;
1133+
u32 ping;
1134+
1135+
ping = IXGBE_PF_CONTROL_MSG;
1136+
if (adapter->vfinfo[vf].clear_to_send)
1137+
ping |= IXGBE_VT_MSGTYPE_CTS;
1138+
ixgbe_write_mbx(hw, &ping, 1, vf);
1139+
}
1140+
11271141
void ixgbe_ping_all_vfs(struct ixgbe_adapter *adapter)
11281142
{
11291143
struct ixgbe_hw *hw = &adapter->hw;
@@ -1416,6 +1430,28 @@ int ixgbe_ndo_set_vf_rss_query_en(struct net_device *netdev, int vf,
14161430
return 0;
14171431
}
14181432

1433+
int ixgbe_ndo_set_vf_trust(struct net_device *netdev, int vf, bool setting)
1434+
{
1435+
struct ixgbe_adapter *adapter = netdev_priv(netdev);
1436+
1437+
if (vf >= adapter->num_vfs)
1438+
return -EINVAL;
1439+
1440+
/* nothing to do */
1441+
if (adapter->vfinfo[vf].trusted == setting)
1442+
return 0;
1443+
1444+
adapter->vfinfo[vf].trusted = setting;
1445+
1446+
/* reset VF to reconfigure features */
1447+
adapter->vfinfo[vf].clear_to_send = false;
1448+
ixgbe_ping_vf(adapter, vf);
1449+
1450+
e_info(drv, "VF %u is %strusted\n", vf, setting ? "" : "not ");
1451+
1452+
return 0;
1453+
}
1454+
14191455
int ixgbe_ndo_get_vf_config(struct net_device *netdev,
14201456
int vf, struct ifla_vf_info *ivi)
14211457
{
@@ -1430,5 +1466,6 @@ int ixgbe_ndo_get_vf_config(struct net_device *netdev,
14301466
ivi->qos = adapter->vfinfo[vf].pf_qos;
14311467
ivi->spoofchk = adapter->vfinfo[vf].spoofchk_enabled;
14321468
ivi->rss_query_en = adapter->vfinfo[vf].rss_query_enabled;
1469+
ivi->trusted = adapter->vfinfo[vf].trusted;
14331470
return 0;
14341471
}

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate,
4949
int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting);
5050
int ixgbe_ndo_set_vf_rss_query_en(struct net_device *netdev, int vf,
5151
bool setting);
52+
int ixgbe_ndo_set_vf_trust(struct net_device *netdev, int vf, bool setting);
5253
int ixgbe_ndo_get_vf_config(struct net_device *netdev,
5354
int vf, struct ifla_vf_info *ivi);
5455
void ixgbe_check_vf_rate_limit(struct ixgbe_adapter *adapter);

0 commit comments

Comments
 (0)