X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fi40e%2Fi40e_vf_representor.c;h=633dca6c3ae9a1763c7cc00ae0e8c74bf525eee4;hb=6d13ea8e8e49ab957deae2bba5ecf4a4bfe747d1;hp=6026ec933190ac15e5b3328dcaebbf1b0034f060;hpb=8973508a0cb3af9178c532c8073784800804e918;p=dpdk.git diff --git a/drivers/net/i40e/i40e_vf_representor.c b/drivers/net/i40e/i40e_vf_representor.c index 6026ec9331..633dca6c3a 100644 --- a/drivers/net/i40e/i40e_vf_representor.c +++ b/drivers/net/i40e/i40e_vf_representor.c @@ -48,6 +48,7 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev, DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM; dev_info->tx_offload_capa = + DEV_TX_OFFLOAD_MULTI_SEGS | DEV_TX_OFFLOAD_VLAN_INSERT | DEV_TX_OFFLOAD_QINQ_INSERT | DEV_TX_OFFLOAD_IPV4_CKSUM | @@ -139,15 +140,126 @@ i40e_vf_representor_tx_queue_setup(__rte_unused struct rte_eth_dev *dev, return 0; } +static void +i40evf_stat_update_48(uint64_t *offset, + uint64_t *stat) +{ + if (*stat >= *offset) + *stat = *stat - *offset; + else + *stat = (uint64_t)((*stat + + ((uint64_t)1 << I40E_48_BIT_WIDTH)) - *offset); + + *stat &= I40E_48_BIT_MASK; +} + +static void +i40evf_stat_update_32(uint64_t *offset, + uint64_t *stat) +{ + if (*stat >= *offset) + *stat = (uint64_t)(*stat - *offset); + else + *stat = (uint64_t)((*stat + + ((uint64_t)1 << I40E_32_BIT_WIDTH)) - *offset); +} + +static int +rte_pmd_i40e_get_vf_native_stats(uint16_t port, + uint16_t vf_id, + struct i40e_eth_stats *stats) +{ + struct rte_eth_dev *dev; + struct i40e_pf *pf; + struct i40e_vsi *vsi; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + + dev = &rte_eth_devices[port]; + + if (!is_i40e_supported(dev)) + return -ENOTSUP; + + pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + + if (vf_id >= pf->vf_num || !pf->vfs) { + PMD_DRV_LOG(ERR, "Invalid VF ID."); + return -EINVAL; + } + + vsi = pf->vfs[vf_id].vsi; + if (!vsi) { + PMD_DRV_LOG(ERR, "Invalid VSI."); + return -EINVAL; + } + + i40e_update_vsi_stats(vsi); + memcpy(stats, &vsi->eth_stats, sizeof(vsi->eth_stats)); + + return 0; +} + static int i40e_vf_representor_stats_get(struct rte_eth_dev *ethdev, struct rte_eth_stats *stats) { struct i40e_vf_representor *representor = ethdev->data->dev_private; + struct i40e_eth_stats native_stats; + int ret; - return rte_pmd_i40e_get_vf_stats( + ret = rte_pmd_i40e_get_vf_native_stats( representor->adapter->eth_dev->data->port_id, - representor->vf_id, stats); + representor->vf_id, &native_stats); + if (ret == 0) { + i40evf_stat_update_48( + &representor->stats_offset.rx_bytes, + &native_stats.rx_bytes); + i40evf_stat_update_48( + &representor->stats_offset.rx_unicast, + &native_stats.rx_unicast); + i40evf_stat_update_48( + &representor->stats_offset.rx_multicast, + &native_stats.rx_multicast); + i40evf_stat_update_48( + &representor->stats_offset.rx_broadcast, + &native_stats.rx_broadcast); + i40evf_stat_update_32( + &representor->stats_offset.rx_discards, + &native_stats.rx_discards); + i40evf_stat_update_32( + &representor->stats_offset.rx_unknown_protocol, + &native_stats.rx_unknown_protocol); + i40evf_stat_update_48( + &representor->stats_offset.tx_bytes, + &native_stats.tx_bytes); + i40evf_stat_update_48( + &representor->stats_offset.tx_unicast, + &native_stats.tx_unicast); + i40evf_stat_update_48( + &representor->stats_offset.tx_multicast, + &native_stats.tx_multicast); + i40evf_stat_update_48( + &representor->stats_offset.tx_broadcast, + &native_stats.tx_broadcast); + i40evf_stat_update_32( + &representor->stats_offset.tx_errors, + &native_stats.tx_errors); + i40evf_stat_update_32( + &representor->stats_offset.tx_discards, + &native_stats.tx_discards); + + stats->ipackets = native_stats.rx_unicast + + native_stats.rx_multicast + + native_stats.rx_broadcast; + stats->opackets = native_stats.tx_unicast + + native_stats.tx_multicast + + native_stats.tx_broadcast; + stats->ibytes = native_stats.rx_bytes; + stats->obytes = native_stats.tx_bytes; + stats->ierrors = native_stats.rx_discards; + stats->oerrors = native_stats.tx_errors + native_stats.tx_discards; + } + return ret; } static void @@ -155,9 +267,9 @@ i40e_vf_representor_stats_reset(struct rte_eth_dev *ethdev) { struct i40e_vf_representor *representor = ethdev->data->dev_private; - rte_pmd_i40e_reset_vf_stats( + rte_pmd_i40e_get_vf_native_stats( representor->adapter->eth_dev->data->port_id, - representor->vf_id); + representor->vf_id, &representor->stats_offset); } static void @@ -212,7 +324,7 @@ i40e_vf_representor_mac_addr_remove(struct rte_eth_dev *ethdev, uint32_t index) static int i40e_vf_representor_mac_addr_set(struct rte_eth_dev *ethdev, - struct ether_addr *mac_addr) + struct rte_ether_addr *mac_addr) { struct i40e_vf_representor *representor = ethdev->data->dev_private; @@ -267,7 +379,8 @@ i40e_vf_representor_vlan_offload_set(struct rte_eth_dev *ethdev, int mask) if (mask & ETH_VLAN_FILTER_MASK) { /* Enable or disable VLAN filtering offload */ - if (ethdev->data->dev_conf.rxmode.hw_vlan_filter) + if (ethdev->data->dev_conf.rxmode.offloads & + DEV_RX_OFFLOAD_VLAN_FILTER) return i40e_vsi_config_vlan_filter(vsi, TRUE); else return i40e_vsi_config_vlan_filter(vsi, FALSE); @@ -275,7 +388,8 @@ i40e_vf_representor_vlan_offload_set(struct rte_eth_dev *ethdev, int mask) if (mask & ETH_VLAN_STRIP_MASK) { /* Enable or disable VLAN stripping offload */ - if (ethdev->data->dev_conf.rxmode.hw_vlan_strip) + if (ethdev->data->dev_conf.rxmode.offloads & + DEV_RX_OFFLOAD_VLAN_STRIP) return i40e_vsi_config_vlan_stripping(vsi, TRUE); else return i40e_vsi_config_vlan_stripping(vsi, FALSE); @@ -306,7 +420,7 @@ i40e_vf_representor_vlan_pvid_set(struct rte_eth_dev *ethdev, uint16_t vlan_id, representor->vf_id, vlan_id); } -struct eth_dev_ops i40e_representor_dev_ops = { +static const struct eth_dev_ops i40e_representor_dev_ops = { .dev_infos_get = i40e_vf_representor_dev_infos_get, .dev_start = i40e_vf_representor_dev_start, @@ -373,9 +487,6 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) if (representor->vf_id >= pf->vf_num) return -ENODEV; - /** representor shares the same driver as it's PF device */ - ethdev->device->driver = representor->adapter->eth_dev->device->driver; - /* Set representor device ops */ ethdev->dev_ops = &i40e_representor_dev_ops; @@ -393,6 +504,7 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) } ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR; + ethdev->data->representor_id = representor->vf_id; /* Setting the number queues allocated to the VF */ ethdev->data->nb_rx_queues = vf->vsi->nb_qps; @@ -412,7 +524,10 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) } int -i40e_vf_representor_uninit(struct rte_eth_dev *ethdev __rte_unused) +i40e_vf_representor_uninit(struct rte_eth_dev *ethdev) { + /* mac_addrs must not be freed because part of i40e_pf_vf */ + ethdev->data->mac_addrs = NULL; + return 0; }