X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fice%2Fice_dcf_ethdev.c;h=e0772295e91688874ae25d5dd2ba95851ee53a39;hb=e8a419d6de4b251e84a36d09e388942283d09adf;hp=a9e78064d4f6cd58fc34a3fe1d1ab315ae4204f8;hpb=5674465a32c895ff9eb74280b29cacd15bf8db59;p=dpdk.git diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index a9e78064d4..e0772295e9 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -26,6 +26,13 @@ #include "ice_dcf_ethdev.h" #include "ice_rxtx.h" +static int +ice_dcf_dev_udp_tunnel_port_add(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *udp_tunnel); +static int +ice_dcf_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *udp_tunnel); + static uint16_t ice_dcf_recv_pkts(__rte_unused void *rx_queue, __rte_unused struct rte_mbuf **bufs, @@ -60,23 +67,23 @@ ice_dcf_init_rxq(struct rte_eth_dev *dev, struct ice_rx_queue *rxq) * correctly. */ if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { - if (max_pkt_len <= RTE_ETHER_MAX_LEN || + if (max_pkt_len <= ICE_ETH_MAX_LEN || max_pkt_len > ICE_FRAME_SIZE_MAX) { PMD_DRV_LOG(ERR, "maximum packet length must be " "larger than %u and smaller than %u, " "as jumbo frame is enabled", - (uint32_t)RTE_ETHER_MAX_LEN, + (uint32_t)ICE_ETH_MAX_LEN, (uint32_t)ICE_FRAME_SIZE_MAX); return -EINVAL; } } else { if (max_pkt_len < RTE_ETHER_MIN_LEN || - max_pkt_len > RTE_ETHER_MAX_LEN) { + max_pkt_len > ICE_ETH_MAX_LEN) { PMD_DRV_LOG(ERR, "maximum packet length must be " "larger than %u and smaller than %u, " "as jumbo frame is disabled", (uint32_t)RTE_ETHER_MIN_LEN, - (uint32_t)RTE_ETHER_MAX_LEN); + (uint32_t)ICE_ETH_MAX_LEN); return -EINVAL; } } @@ -601,6 +608,9 @@ ice_dcf_dev_stop(struct rte_eth_dev *dev) return 0; } + /* Stop the VF representors for this device */ + ice_dcf_vf_repr_stop_all(dcf_ad); + ice_dcf_stop_queues(dev); rte_intr_efd_disable(intr_handle); @@ -849,6 +859,30 @@ ice_dcf_stats_reset(struct rte_eth_dev *dev) return 0; } +static void +ice_dcf_free_repr_info(struct ice_dcf_adapter *dcf_adapter) +{ + if (dcf_adapter->repr_infos) { + rte_free(dcf_adapter->repr_infos); + dcf_adapter->repr_infos = NULL; + } +} + +static int +ice_dcf_init_repr_info(struct ice_dcf_adapter *dcf_adapter) +{ + dcf_adapter->repr_infos = + rte_calloc("ice_dcf_rep_info", + dcf_adapter->real_hw.num_vfs, + sizeof(dcf_adapter->repr_infos[0]), 0); + if (!dcf_adapter->repr_infos) { + PMD_DRV_LOG(ERR, "Failed to alloc memory for VF representors\n"); + return -ENOMEM; + } + + return 0; +} + static int ice_dcf_dev_close(struct rte_eth_dev *dev) { @@ -857,6 +891,7 @@ ice_dcf_dev_close(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + ice_dcf_free_repr_info(adapter); ice_dcf_uninit_parent_adapter(dev); ice_dcf_uninit_hw(dev, &adapter->real_hw); @@ -870,6 +905,64 @@ ice_dcf_link_update(__rte_unused struct rte_eth_dev *dev, return 0; } +/* Add UDP tunneling port */ +static int +ice_dcf_dev_udp_tunnel_port_add(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *udp_tunnel) +{ + struct ice_dcf_adapter *adapter = dev->data->dev_private; + struct ice_adapter *parent_adapter = &adapter->parent; + struct ice_hw *parent_hw = &parent_adapter->hw; + int ret = 0; + + if (!udp_tunnel) + return -EINVAL; + + switch (udp_tunnel->prot_type) { + case RTE_TUNNEL_TYPE_VXLAN: + ret = ice_create_tunnel(parent_hw, TNL_VXLAN, + udp_tunnel->udp_port); + break; + case RTE_TUNNEL_TYPE_ECPRI: + ret = ice_create_tunnel(parent_hw, TNL_ECPRI, + udp_tunnel->udp_port); + break; + default: + PMD_DRV_LOG(ERR, "Invalid tunnel type"); + ret = -EINVAL; + break; + } + + return ret; +} + +/* Delete UDP tunneling port */ +static int +ice_dcf_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *udp_tunnel) +{ + struct ice_dcf_adapter *adapter = dev->data->dev_private; + struct ice_adapter *parent_adapter = &adapter->parent; + struct ice_hw *parent_hw = &parent_adapter->hw; + int ret = 0; + + if (!udp_tunnel) + return -EINVAL; + + switch (udp_tunnel->prot_type) { + case RTE_TUNNEL_TYPE_VXLAN: + case RTE_TUNNEL_TYPE_ECPRI: + ret = ice_destroy_tunnel(parent_hw, udp_tunnel->udp_port, 0); + break; + default: + PMD_DRV_LOG(ERR, "Invalid tunnel type"); + ret = -EINVAL; + break; + } + + return ret; +} + static const struct eth_dev_ops ice_dcf_eth_dev_ops = { .dev_start = ice_dcf_dev_start, .dev_stop = ice_dcf_dev_stop, @@ -892,6 +985,8 @@ static const struct eth_dev_ops ice_dcf_eth_dev_ops = { .allmulticast_enable = ice_dcf_dev_allmulticast_enable, .allmulticast_disable = ice_dcf_dev_allmulticast_disable, .filter_ctrl = ice_dcf_dev_filter_ctrl, + .udp_tunnel_port_add = ice_dcf_dev_udp_tunnel_port_add, + .udp_tunnel_port_del = ice_dcf_dev_udp_tunnel_port_del, }; static int @@ -1000,21 +1095,26 @@ eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv, return -ENODEV; dcf_adapter = dcf_ethdev->data->dev_private; + ret = ice_dcf_init_repr_info(dcf_adapter); + if (ret) + return ret; if (eth_da.nb_representor_ports > dcf_adapter->real_hw.num_vfs || eth_da.nb_representor_ports >= RTE_MAX_ETHPORTS) { PMD_DRV_LOG(ERR, "the number of port representors is too large: %u", eth_da.nb_representor_ports); + ice_dcf_free_repr_info(dcf_adapter); return -EINVAL; } dcf_vsi_id = dcf_adapter->real_hw.vsi_id | VIRTCHNL_DCF_VF_VSI_VALID; - repr_param.adapter = dcf_adapter; + repr_param.dcf_eth_dev = dcf_ethdev; repr_param.switch_domain_id = 0; for (i = 0; i < eth_da.nb_representor_ports; i++) { uint16_t vf_id = eth_da.representor_ports[i]; + struct rte_eth_dev *vf_rep_eth_dev; if (vf_id >= dcf_adapter->real_hw.num_vfs) { PMD_DRV_LOG(ERR, "VF ID %u is out of range (0 ~ %u)", @@ -1041,6 +1141,18 @@ eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv, repr_name); break; } + + vf_rep_eth_dev = rte_eth_dev_allocated(repr_name); + if (!vf_rep_eth_dev) { + PMD_DRV_LOG(ERR, + "Failed to find the ethdev for DCF VF representor: %s", + repr_name); + ret = -ENODEV; + break; + } + + dcf_adapter->repr_infos[vf_id].vf_rep_eth_dev = vf_rep_eth_dev; + dcf_adapter->num_reprs++; } return ret;