Skip to content

Commit 12bedeb

Browse files
committed
ping all or specified VF
1 parent 604c26d commit 12bedeb

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

drivers/net/ixgbe/ixgbe_ethdev.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ static int ixgbe_set_pool_vlan_anti_spoof(struct rte_eth_dev *dev,
252252
uint32_t vf, uint8_t on);
253253
static int ixgbe_set_pool_mac_anti_spoof(struct rte_eth_dev *dev,
254254
uint32_t vf, uint8_t on);
255+
static int ixgbe_ping_vfs(struct rte_eth_dev *dev, int32_t vf);
255256
static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
256257
struct rte_eth_mirror_conf *mirror_conf,
257258
uint8_t rule_id, uint8_t on);
@@ -467,6 +468,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
467468
.set_vf_vlan_filter = ixgbe_set_pool_vlan_filter,
468469
.set_vf_vlan_anti_spoof = ixgbe_set_pool_vlan_anti_spoof,
469470
.set_vf_mac_anti_spoof = ixgbe_set_pool_mac_anti_spoof,
471+
.ping_vfs = ixgbe_ping_vfs,
470472
.set_queue_rate_limit = ixgbe_set_queue_rate_limit,
471473
.set_vf_rate_limit = ixgbe_set_vf_rate_limit,
472474
.reta_update = ixgbe_dev_rss_reta_update,
@@ -4330,6 +4332,32 @@ ixgbe_set_pool_mac_anti_spoof(struct rte_eth_dev *dev,
43304332
return ret;
43314333
}
43324334

4335+
static int
4336+
ixgbe_ping_vfs(struct rte_eth_dev *dev, int32_t vf)
4337+
{
4338+
int ret = 0;
4339+
struct ixgbe_hw *hw =
4340+
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4341+
4342+
struct ixgbe_vf_info *vfinfo =
4343+
*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
4344+
4345+
u32 ping;
4346+
int i;
4347+
4348+
for (i = 0; i < dev->pci_dev->max_vfs; i++) {
4349+
ping = IXGBE_PF_CONTROL_MSG;
4350+
if (vfinfo[i].clear_to_send)
4351+
ping |= IXGBE_VT_MSGTYPE_CTS;
4352+
4353+
/* ping every VF or only one specified */
4354+
if (vf < 0 || vf == i)
4355+
ixgbe_write_mbx(hw, &ping, 1, i);
4356+
}
4357+
4358+
return ret;
4359+
}
4360+
43334361
#define IXGBE_MRCTL_VPME 0x01 /* Virtual Pool Mirroring. */
43344362
#define IXGBE_MRCTL_UPME 0x02 /* Uplink Port Mirroring. */
43354363
#define IXGBE_MRCTL_DPME 0x04 /* Downlink Port Mirroring. */

lib/librte_ether/rte_ethdev.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,6 +2338,22 @@ rte_eth_dev_set_vf_mac_anti_spoof(uint8_t port_id,
23382338
vf, on);
23392339
}
23402340

2341+
int
2342+
rte_eth_dev_ping_vfs(uint8_t port_id, int32_t vf)
2343+
{
2344+
struct rte_eth_dev *dev;
2345+
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
2346+
2347+
dev = &rte_eth_devices[port_id];
2348+
if ( vf > 64) {
2349+
RTE_PMD_DEBUG_TRACE("VF ping: VM %d > 64\n", vf);
2350+
return -EINVAL;
2351+
}
2352+
2353+
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->ping_vfs, -ENOTSUP);
2354+
return (*dev->dev_ops->ping_vfs)(dev, vf);
2355+
}
2356+
23412357
int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
23422358
uint16_t tx_rate)
23432359
{

lib/librte_ether/rte_ethdev.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,10 @@ typedef int (*eth_set_vf_mac_anti_spoof_t)(struct rte_eth_dev *dev,
11931193
uint8_t on);
11941194
/**< @internal Set VF MAC anti spoof */
11951195

1196+
typedef int (*eth_ping_vfs_t)(struct rte_eth_dev *dev,
1197+
int32_t vf);
1198+
/**< @internal ping one or all vf's */
1199+
11961200
typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
11971201
uint16_t queue_idx,
11981202
uint16_t tx_rate);
@@ -1395,6 +1399,7 @@ struct eth_dev_ops {
13951399
eth_set_vf_vlan_filter_t set_vf_vlan_filter; /**< Set VF VLAN filter */
13961400
eth_set_vf_vlan_anti_spoof_t set_vf_vlan_anti_spoof; /**< Set VF VLAN anti spoof */
13971401
eth_set_vf_mac_anti_spoof_t set_vf_mac_anti_spoof; /**< Set VF MAC anti spoof */
1402+
eth_ping_vfs_t ping_vfs; /**< Ping one or all VF's */
13981403
eth_udp_tunnel_add_t udp_tunnel_add;
13991404
eth_udp_tunnel_del_t udp_tunnel_del;
14001405
eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit */
@@ -3162,6 +3167,24 @@ rte_eth_dev_set_vf_mac_anti_spoof(uint8_t port,
31623167
uint32_t vf,
31633168
uint8_t on);
31643169

3170+
/**
3171+
* Ping all or specified VF
3172+
*
3173+
* @param port_id
3174+
* The port identifier of the Ethernet device.
3175+
* @param vf
3176+
* ID specifying VF ID to ping or all if -1.
3177+
*
3178+
* @return
3179+
* - (0) if successful.
3180+
* - (-ENOTSUP) if hardware doesn't support this feature.
3181+
* - (-ENODEV) if *port_id* invalid.
3182+
* - (-EINVAL) if bad parameter.
3183+
*/
3184+
int
3185+
rte_eth_dev_ping_vfs(uint8_t port,
3186+
int32_t vf);
3187+
31653188
/**
31663189
* Set a traffic mirroring rule on an Ethernet device
31673190
*

0 commit comments

Comments
 (0)