Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/85125/?format=api
http://patchwork.dpdk.org/api/patches/85125/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20201214070707.98564-4-haiyue.wang@intel.com/", "project": { "id": 1, "url": "http://patchwork.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20201214070707.98564-4-haiyue.wang@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20201214070707.98564-4-haiyue.wang@intel.com", "date": "2020-12-14T07:07:06", "name": "[v1,4/5] net/ice: add DCF port representor", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "f004bf9364e0c4c838ddd2492b21b8ac4e55c6a8", "submitter": { "id": 1044, "url": "http://patchwork.dpdk.org/api/people/1044/?format=api", "name": "Wang, Haiyue", "email": "haiyue.wang@intel.com" }, "delegate": { "id": 1540, "url": "http://patchwork.dpdk.org/api/users/1540/?format=api", "username": "qzhan15", "first_name": "Qi", "last_name": "Zhang", "email": "qi.z.zhang@intel.com" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20201214070707.98564-4-haiyue.wang@intel.com/mbox/", "series": [ { "id": 14285, "url": "http://patchwork.dpdk.org/api/series/14285/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=14285", "date": "2020-12-14T07:07:06", "name": "[v1,1/5] common/iavf: new VLAN opcode", "version": 1, "mbox": "http://patchwork.dpdk.org/series/14285/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/85125/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/85125/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 30C72A09E9;\n\tMon, 14 Dec 2020 08:22:02 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 5B4FC37B7;\n\tMon, 14 Dec 2020 08:22:00 +0100 (CET)", "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n by dpdk.org (Postfix) with ESMTP id 54A5F3257\n for <dev@dpdk.org>; Mon, 14 Dec 2020 08:21:58 +0100 (CET)", "from orsmga008.jf.intel.com ([10.7.209.65])\n by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 13 Dec 2020 23:21:54 -0800", "from npg-dpdk-haiyue-3.sh.intel.com ([10.67.118.190])\n by orsmga008.jf.intel.com with ESMTP; 13 Dec 2020 23:21:52 -0800" ], "IronPort-SDR": [ "\n vYz/TvaTFgkvlX/GRxRu4qS30tqnUvXeOU0Nv4Ps2Ypam3E5wY58HI5Md3W17zqyTfM42giBGF\n bVrFO9TYhnPg==", "\n 9ki7OH4ukRlArWUbif3VuUpS8gkZSBZ8+/AXYgmVxsHZqO+TrI786hmCAKHOdDPBR469J55rxy\n fEkuldZuEHKg==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6000,8403,9834\"; a=\"174778604\"", "E=Sophos;i=\"5.78,417,1599548400\"; d=\"scan'208\";a=\"174778604\"", "E=Sophos;i=\"5.78,417,1599548400\"; d=\"scan'208\";a=\"367173524\"" ], "X-ExtLoop1": "1", "From": "Haiyue Wang <haiyue.wang@intel.com>", "To": "dev@dpdk.org", "Cc": "qiming.yang@intel.com, jingjing.wu@intel.com, qi.z.zhang@intel.com,\n Haiyue Wang <haiyue.wang@intel.com>", "Date": "Mon, 14 Dec 2020 15:07:06 +0800", "Message-Id": "<20201214070707.98564-4-haiyue.wang@intel.com>", "X-Mailer": "git-send-email 2.29.2", "In-Reply-To": "<20201214070707.98564-1-haiyue.wang@intel.com>", "References": "<20201214070707.98564-1-haiyue.wang@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v1 4/5] net/ice: add DCF port representor", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Add the DCF port representor infrastructure for the VFs of DCF attached\nPF. Then the standard ethdev API can be used to configure the VFs.\n\nThe main function is VLAN related.\n\nSigned-off-by: Qiming Yang <qiming.yang@intel.com>\nSigned-off-by: Haiyue Wang <haiyue.wang@intel.com>\n---\n drivers/net/ice/ice_dcf.c | 1 +\n drivers/net/ice/ice_dcf_ethdev.c | 91 +++++-\n drivers/net/ice/ice_dcf_ethdev.h | 20 ++\n drivers/net/ice/ice_dcf_vf_representor.c | 356 +++++++++++++++++++++++\n drivers/net/ice/meson.build | 1 +\n 5 files changed, 462 insertions(+), 7 deletions(-)\n create mode 100644 drivers/net/ice/ice_dcf_vf_representor.c", "diff": "diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c\nindex 44dbd3bb8..4a9af3292 100644\n--- a/drivers/net/ice/ice_dcf.c\n+++ b/drivers/net/ice/ice_dcf.c\n@@ -234,6 +234,7 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)\n \n \tcaps = VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_RX_POLLING |\n \t VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_CAP_DCF |\n+\t VIRTCHNL_VF_OFFLOAD_VLAN_V2 |\n \t VF_BASE_MODE_OFFLOADS | VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC;\n \n \terr = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,\ndiff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c\nindex b0b2ecb0d..a9e78064d 100644\n--- a/drivers/net/ice/ice_dcf_ethdev.c\n+++ b/drivers/net/ice/ice_dcf_ethdev.c\n@@ -970,20 +970,97 @@ ice_dcf_cap_selected(struct rte_devargs *devargs)\n \treturn ret;\n }\n \n-static int eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,\n-\t\t\t struct rte_pci_device *pci_dev)\n+static int\n+eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,\n+\t\t struct rte_pci_device *pci_dev)\n {\n+\tstruct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };\n+\tstruct ice_dcf_vf_repr_param repr_param;\n+\tchar repr_name[RTE_ETH_NAME_MAX_LEN];\n+\tstruct ice_dcf_adapter *dcf_adapter;\n+\tstruct rte_eth_dev *dcf_ethdev;\n+\tuint16_t dcf_vsi_id;\n+\tint i, ret;\n+\n \tif (!ice_dcf_cap_selected(pci_dev->device.devargs))\n \t\treturn 1;\n \n-\treturn rte_eth_dev_pci_generic_probe(pci_dev,\n-\t\t\t\t\t sizeof(struct ice_dcf_adapter),\n-\t\t\t\t\t ice_dcf_dev_init);\n+\tret = rte_eth_devargs_parse(pci_dev->device.devargs->args, ð_da);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = rte_eth_dev_pci_generic_probe(pci_dev,\n+\t\t\t\t\t sizeof(struct ice_dcf_adapter),\n+\t\t\t\t\t ice_dcf_dev_init);\n+\tif (ret || !eth_da.nb_representor_ports)\n+\t\treturn ret;\n+\n+\tdcf_ethdev = rte_eth_dev_allocated(pci_dev->device.name);\n+\tif (dcf_ethdev == NULL)\n+\t\treturn -ENODEV;\n+\n+\tdcf_adapter = dcf_ethdev->data->dev_private;\n+\n+\tif (eth_da.nb_representor_ports > dcf_adapter->real_hw.num_vfs ||\n+\t eth_da.nb_representor_ports >= RTE_MAX_ETHPORTS) {\n+\t\tPMD_DRV_LOG(ERR, \"the number of port representors is too large: %u\",\n+\t\t\t eth_da.nb_representor_ports);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tdcf_vsi_id = dcf_adapter->real_hw.vsi_id | VIRTCHNL_DCF_VF_VSI_VALID;\n+\n+\trepr_param.adapter = dcf_adapter;\n+\trepr_param.switch_domain_id = 0;\n+\n+\tfor (i = 0; i < eth_da.nb_representor_ports; i++) {\n+\t\tuint16_t vf_id = eth_da.representor_ports[i];\n+\n+\t\tif (vf_id >= dcf_adapter->real_hw.num_vfs) {\n+\t\t\tPMD_DRV_LOG(ERR, \"VF ID %u is out of range (0 ~ %u)\",\n+\t\t\t\t vf_id, dcf_adapter->real_hw.num_vfs - 1);\n+\t\t\tret = -EINVAL;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (dcf_adapter->real_hw.vf_vsi_map[vf_id] == dcf_vsi_id) {\n+\t\t\tPMD_DRV_LOG(ERR, \"VF ID %u is DCF's ID.\\n\", vf_id);\n+\t\t\tret = -EINVAL;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\trepr_param.vf_id = vf_id;\n+\t\tsnprintf(repr_name, sizeof(repr_name), \"net_%s_representor_%u\",\n+\t\t\t pci_dev->device.name, vf_id);\n+\t\tret = rte_eth_dev_create(&pci_dev->device, repr_name,\n+\t\t\t\t\t sizeof(struct ice_dcf_vf_repr),\n+\t\t\t\t\t NULL, NULL, ice_dcf_vf_repr_init,\n+\t\t\t\t\t &repr_param);\n+\t\tif (ret) {\n+\t\t\tPMD_DRV_LOG(ERR, \"failed to create DCF VF representor %s\",\n+\t\t\t\t repr_name);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\treturn ret;\n }\n \n-static int eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)\n+static int\n+eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)\n {\n-\treturn rte_eth_dev_pci_generic_remove(pci_dev, ice_dcf_dev_uninit);\n+\tstruct rte_eth_dev *eth_dev;\n+\n+\teth_dev = rte_eth_dev_allocated(pci_dev->device.name);\n+\tif (!eth_dev)\n+\t\treturn 0;\n+\n+\tif (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)\n+\t\treturn rte_eth_dev_pci_generic_remove(pci_dev,\n+\t\t\t\t\t\t ice_dcf_vf_repr_uninit);\n+\telse\n+\t\treturn rte_eth_dev_pci_generic_remove(pci_dev,\n+\t\t\t\t\t\t ice_dcf_dev_uninit);\n }\n \n static const struct rte_pci_id pci_id_ice_dcf_map[] = {\ndiff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h\nindex b54528bea..bd5552332 100644\n--- a/drivers/net/ice/ice_dcf_ethdev.h\n+++ b/drivers/net/ice/ice_dcf_ethdev.h\n@@ -22,9 +22,29 @@ struct ice_dcf_adapter {\n \tstruct ice_dcf_hw real_hw;\n };\n \n+struct ice_dcf_vf_repr_param {\n+\tstruct ice_dcf_adapter *adapter;\n+\tuint16_t switch_domain_id;\n+\tuint16_t vf_id;\n+};\n+\n+struct ice_dcf_vf_repr {\n+\tstruct ice_dcf_adapter *dcf_adapter;\n+\tstruct rte_ether_addr mac_addr;\n+\tuint16_t switch_domain_id;\n+\tuint16_t vf_id;\n+\n+\tuint16_t outer_vlan_tpid;\n+\tuint16_t pvid;\n+\tuint16_t hw_vlan_insert_pvid:1;\n+};\n+\n void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,\n \t\t\t\t uint8_t *msg, uint16_t msglen);\n int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);\n void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);\n \n+int ice_dcf_vf_repr_init(struct rte_eth_dev *ethdev, void *init_param);\n+int ice_dcf_vf_repr_uninit(struct rte_eth_dev *ethdev);\n+\n #endif /* _ICE_DCF_ETHDEV_H_ */\ndiff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c\nnew file mode 100644\nindex 000000000..e9806895d\n--- /dev/null\n+++ b/drivers/net/ice/ice_dcf_vf_representor.c\n@@ -0,0 +1,356 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Intel Corporation\n+ */\n+\n+#include <errno.h>\n+#include <sys/types.h>\n+\n+#include <rte_ethdev.h>\n+\n+#include \"ice_dcf_ethdev.h\"\n+#include \"ice_rxtx.h\"\n+\n+static uint16_t\n+ice_dcf_vf_repr_rx_burst(__rte_unused void *rxq,\n+\t\t\t __rte_unused struct rte_mbuf **rx_pkts,\n+\t\t\t __rte_unused uint16_t nb_pkts)\n+{\n+\treturn 0;\n+}\n+\n+static uint16_t\n+ice_dcf_vf_repr_tx_burst(__rte_unused void *txq,\n+\t\t\t __rte_unused struct rte_mbuf **tx_pkts,\n+\t\t\t __rte_unused uint16_t nb_pkts)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_dev_configure(__rte_unused struct rte_eth_dev *dev)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_dev_start(struct rte_eth_dev *dev)\n+{\n+\tdev->data->dev_link.link_status = ETH_LINK_UP;\n+\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)\n+{\n+\tdev->data->dev_link.link_status = ETH_LINK_DOWN;\n+\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev)\n+{\n+\treturn ice_dcf_vf_repr_uninit(dev);\n+}\n+\n+static int\n+ice_dcf_vf_repr_rx_queue_setup(__rte_unused struct rte_eth_dev *dev,\n+\t\t\t __rte_unused uint16_t queue_id,\n+\t\t\t __rte_unused uint16_t nb_desc,\n+\t\t\t __rte_unused unsigned int socket_id,\n+\t\t\t __rte_unused const struct rte_eth_rxconf *conf,\n+\t\t\t __rte_unused struct rte_mempool *pool)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_tx_queue_setup(__rte_unused struct rte_eth_dev *dev,\n+\t\t\t __rte_unused uint16_t queue_id,\n+\t\t\t __rte_unused uint16_t nb_desc,\n+\t\t\t __rte_unused unsigned int socket_id,\n+\t\t\t __rte_unused const struct rte_eth_txconf *conf)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_promiscuous_enable(__rte_unused struct rte_eth_dev *ethdev)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_promiscuous_disable(__rte_unused struct rte_eth_dev *ethdev)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_allmulticast_enable(__rte_unused struct rte_eth_dev *dev)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_allmulticast_disable(__rte_unused struct rte_eth_dev *dev)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_link_update(__rte_unused struct rte_eth_dev *ethdev,\n+\t\t\t __rte_unused int wait_to_complete)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_dev_info_get(struct rte_eth_dev *dev,\n+\t\t\t struct rte_eth_dev_info *dev_info)\n+{\n+\tstruct ice_dcf_vf_repr *repr = dev->data->dev_private;\n+\tstruct ice_dcf_hw *dcf_hw =\n+\t\t\t\t&repr->dcf_adapter->real_hw;\n+\n+\tdev_info->device = dev->device;\n+\tdev_info->max_mac_addrs = 1;\n+\tdev_info->max_rx_queues = dcf_hw->vsi_res->num_queue_pairs;\n+\tdev_info->max_tx_queues = dcf_hw->vsi_res->num_queue_pairs;\n+\tdev_info->min_rx_bufsize = ICE_BUF_SIZE_MIN;\n+\tdev_info->max_rx_pktlen = ICE_FRAME_SIZE_MAX;\n+\tdev_info->hash_key_size = dcf_hw->vf_res->rss_key_size;\n+\tdev_info->reta_size = dcf_hw->vf_res->rss_lut_size;\n+\tdev_info->flow_type_rss_offloads = ICE_RSS_OFFLOAD_ALL;\n+\n+\tdev_info->rx_offload_capa =\n+\t\tDEV_RX_OFFLOAD_VLAN_STRIP |\n+\t\tDEV_RX_OFFLOAD_IPV4_CKSUM |\n+\t\tDEV_RX_OFFLOAD_UDP_CKSUM |\n+\t\tDEV_RX_OFFLOAD_TCP_CKSUM |\n+\t\tDEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |\n+\t\tDEV_RX_OFFLOAD_SCATTER |\n+\t\tDEV_RX_OFFLOAD_JUMBO_FRAME |\n+\t\tDEV_RX_OFFLOAD_VLAN_FILTER |\n+\t\tDEV_RX_OFFLOAD_VLAN_EXTEND |\n+\t\tDEV_RX_OFFLOAD_RSS_HASH;\n+\tdev_info->tx_offload_capa =\n+\t\tDEV_TX_OFFLOAD_VLAN_INSERT |\n+\t\tDEV_TX_OFFLOAD_IPV4_CKSUM |\n+\t\tDEV_TX_OFFLOAD_UDP_CKSUM |\n+\t\tDEV_TX_OFFLOAD_TCP_CKSUM |\n+\t\tDEV_TX_OFFLOAD_SCTP_CKSUM |\n+\t\tDEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |\n+\t\tDEV_TX_OFFLOAD_TCP_TSO |\n+\t\tDEV_TX_OFFLOAD_VXLAN_TNL_TSO |\n+\t\tDEV_TX_OFFLOAD_GRE_TNL_TSO |\n+\t\tDEV_TX_OFFLOAD_IPIP_TNL_TSO |\n+\t\tDEV_TX_OFFLOAD_GENEVE_TNL_TSO |\n+\t\tDEV_TX_OFFLOAD_MULTI_SEGS;\n+\n+\tdev_info->default_rxconf = (struct rte_eth_rxconf) {\n+\t\t.rx_thresh = {\n+\t\t\t.pthresh = ICE_DEFAULT_RX_PTHRESH,\n+\t\t\t.hthresh = ICE_DEFAULT_RX_HTHRESH,\n+\t\t\t.wthresh = ICE_DEFAULT_RX_WTHRESH,\n+\t\t},\n+\t\t.rx_free_thresh = ICE_DEFAULT_RX_FREE_THRESH,\n+\t\t.rx_drop_en = 0,\n+\t\t.offloads = 0,\n+\t};\n+\n+\tdev_info->default_txconf = (struct rte_eth_txconf) {\n+\t\t.tx_thresh = {\n+\t\t\t.pthresh = ICE_DEFAULT_TX_PTHRESH,\n+\t\t\t.hthresh = ICE_DEFAULT_TX_HTHRESH,\n+\t\t\t.wthresh = ICE_DEFAULT_TX_WTHRESH,\n+\t\t},\n+\t\t.tx_free_thresh = ICE_DEFAULT_TX_FREE_THRESH,\n+\t\t.tx_rs_thresh = ICE_DEFAULT_TX_RSBIT_THRESH,\n+\t\t.offloads = 0,\n+\t};\n+\n+\tdev_info->rx_desc_lim = (struct rte_eth_desc_lim) {\n+\t\t.nb_max = ICE_MAX_RING_DESC,\n+\t\t.nb_min = ICE_MIN_RING_DESC,\n+\t\t.nb_align = ICE_ALIGN_RING_DESC,\n+\t};\n+\n+\tdev_info->tx_desc_lim = (struct rte_eth_desc_lim) {\n+\t\t.nb_max = ICE_MAX_RING_DESC,\n+\t\t.nb_min = ICE_MIN_RING_DESC,\n+\t\t.nb_align = ICE_ALIGN_RING_DESC,\n+\t};\n+\n+\tdev_info->switch_info.name = dcf_hw->eth_dev->device->name;\n+\tdev_info->switch_info.domain_id = repr->switch_domain_id;\n+\tdev_info->switch_info.port_id = repr->vf_id;\n+\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vlan_offload_config(struct ice_dcf_vf_repr *repr,\n+\t\t\t struct virtchnl_dcf_vlan_offload *vlan_offload)\n+{\n+\tstruct dcf_virtchnl_cmd args;\n+\n+\tmemset(&args, 0, sizeof(args));\n+\targs.v_op = VIRTCHNL_OP_DCF_VLAN_OFFLOAD;\n+\targs.req_msg = (uint8_t *)vlan_offload;\n+\targs.req_msglen = sizeof(*vlan_offload);\n+\n+\treturn ice_dcf_execute_virtchnl_cmd(&repr->dcf_adapter->real_hw, &args);\n+}\n+\n+static __rte_always_inline bool\n+ice_dcf_vlan_offload_ena(struct ice_dcf_vf_repr *repr)\n+{\n+\treturn !!(repr->dcf_adapter->real_hw.vf_res->vf_cap_flags &\n+\t\t VIRTCHNL_VF_OFFLOAD_VLAN_V2);\n+}\n+\n+static int\n+ice_dcf_vf_repr_vlan_pvid_set(struct rte_eth_dev *dev,\n+\t\t\t uint16_t pvid, int on)\n+{\n+\tstruct ice_dcf_vf_repr *repr = dev->data->dev_private;\n+\tstruct virtchnl_dcf_vlan_offload vlan_offload;\n+\tint err;\n+\n+\tif (!ice_dcf_vlan_offload_ena(repr))\n+\t\treturn -ENOTSUP;\n+\n+\tmemset(&vlan_offload, 0, sizeof(vlan_offload));\n+\n+\tvlan_offload.vf_id = repr->vf_id;\n+\tvlan_offload.tpid = repr->outer_vlan_tpid;\n+\tvlan_offload.vlan_flags = (VIRTCHNL_DCF_VLAN_TYPE_OUTER <<\n+\t\t\t\t VIRTCHNL_DCF_VLAN_TYPE_S) |\n+\t\t\t\t (VIRTCHNL_DCF_VLAN_INSERT_PORT_BASED <<\n+\t\t\t\t VIRTCHNL_DCF_VLAN_INSERT_MODE_S);\n+\tvlan_offload.vlan_id = on ? pvid : 0;\n+\n+\terr = ice_dcf_vlan_offload_config(repr, &vlan_offload);\n+\tif (!err) {\n+\t\trepr->pvid = vlan_offload.vlan_id;\n+\t\trepr->hw_vlan_insert_pvid = on ? 1 : 0;\n+\t}\n+\n+\treturn err;\n+}\n+\n+static int\n+ice_dcf_vf_repr_vlan_offload_set(struct rte_eth_dev *dev, int mask)\n+{\n+\tstruct ice_dcf_vf_repr *repr = dev->data->dev_private;\n+\tstruct rte_eth_rxmode *rxmode;\n+\n+\tif (!ice_dcf_vlan_offload_ena(repr))\n+\t\treturn -ENOTSUP;\n+\n+\trxmode = &dev->data->dev_conf.rxmode;\n+\n+\tif (mask & ETH_VLAN_EXTEND_MASK) {\n+\t\tif (!(rxmode->offloads & DEV_RX_OFFLOAD_VLAN_EXTEND))\n+\t\t\tice_dcf_vf_repr_vlan_pvid_set(dev, 0, 0);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+ice_dcf_vf_repr_vlan_tpid_set(struct rte_eth_dev *dev,\n+\t\t\t enum rte_vlan_type vlan_type, uint16_t tpid)\n+{\n+\tstruct ice_dcf_vf_repr *repr = dev->data->dev_private;\n+\n+\tif (!ice_dcf_vlan_offload_ena(repr))\n+\t\treturn -ENOTSUP;\n+\n+\tif (vlan_type != ETH_VLAN_TYPE_INNER &&\n+\t vlan_type != ETH_VLAN_TYPE_OUTER) {\n+\t\tPMD_DRV_LOG(ERR, \"Unsupported vlan type %d\", vlan_type);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (vlan_type == ETH_VLAN_TYPE_INNER) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t \"Can accelerate only outer VLAN in QinQ\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (!(dev->data->dev_conf.rxmode.offloads &\n+\t DEV_RX_OFFLOAD_VLAN_EXTEND)) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t \"QinQ not enabled.\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (tpid != RTE_ETHER_TYPE_QINQ ||\n+\t tpid != RTE_ETHER_TYPE_VLAN ||\n+\t tpid != RTE_ETHER_TYPE_QINQ1) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t \"Invalid TPID: 0x%04x\\n\", tpid);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trepr->outer_vlan_tpid = tpid;\n+\n+\treturn ice_dcf_vf_repr_vlan_pvid_set(dev,\n+\t\t\t\t\t repr->pvid,\n+\t\t\t\t\t repr->hw_vlan_insert_pvid);\n+}\n+\n+static const struct eth_dev_ops ice_dcf_vf_repr_dev_ops = {\n+\t.dev_configure = ice_dcf_vf_repr_dev_configure,\n+\t.dev_start = ice_dcf_vf_repr_dev_start,\n+\t.dev_stop = ice_dcf_vf_repr_dev_stop,\n+\t.dev_close = ice_dcf_vf_repr_dev_close,\n+\t.dev_infos_get = ice_dcf_vf_repr_dev_info_get,\n+\t.rx_queue_setup = ice_dcf_vf_repr_rx_queue_setup,\n+\t.tx_queue_setup = ice_dcf_vf_repr_tx_queue_setup,\n+\t.promiscuous_enable = ice_dcf_vf_repr_promiscuous_enable,\n+\t.promiscuous_disable = ice_dcf_vf_repr_promiscuous_disable,\n+\t.allmulticast_enable = ice_dcf_vf_repr_allmulticast_enable,\n+\t.allmulticast_disable = ice_dcf_vf_repr_allmulticast_disable,\n+\t.link_update = ice_dcf_vf_repr_link_update,\n+\t.vlan_offload_set = ice_dcf_vf_repr_vlan_offload_set,\n+\t.vlan_pvid_set = ice_dcf_vf_repr_vlan_pvid_set,\n+\t.vlan_tpid_set = ice_dcf_vf_repr_vlan_tpid_set,\n+};\n+\n+int\n+ice_dcf_vf_repr_init(struct rte_eth_dev *ethdev, void *init_param)\n+{\n+\tstruct ice_dcf_vf_repr *repr = ethdev->data->dev_private;\n+\tstruct ice_dcf_vf_repr_param *param = init_param;\n+\n+\trepr->dcf_adapter = param->adapter;\n+\trepr->switch_domain_id = param->switch_domain_id;\n+\trepr->vf_id = param->vf_id;\n+\trepr->outer_vlan_tpid = RTE_ETHER_TYPE_VLAN;\n+\n+\tethdev->dev_ops = &ice_dcf_vf_repr_dev_ops;\n+\n+\tethdev->rx_pkt_burst = ice_dcf_vf_repr_rx_burst;\n+\tethdev->tx_pkt_burst = ice_dcf_vf_repr_tx_burst;\n+\n+\tethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;\n+\tethdev->data->representor_id = repr->vf_id;\n+\n+\tethdev->data->mac_addrs = &repr->mac_addr;\n+\n+\trte_eth_random_addr(repr->mac_addr.addr_bytes);\n+\n+\treturn 0;\n+}\n+\n+int\n+ice_dcf_vf_repr_uninit(struct rte_eth_dev *ethdev)\n+{\n+\tethdev->data->mac_addrs = NULL;\n+\n+\treturn 0;\n+}\ndiff --git a/drivers/net/ice/meson.build b/drivers/net/ice/meson.build\nindex 7b291269d..d58936089 100644\n--- a/drivers/net/ice/meson.build\n+++ b/drivers/net/ice/meson.build\n@@ -61,6 +61,7 @@ if arch_subdir == 'x86'\n endif\n \n sources += files('ice_dcf.c',\n+\t\t 'ice_dcf_vf_representor.c',\n \t\t 'ice_dcf_ethdev.c',\n \t\t 'ice_dcf_parent.c')\n \n", "prefixes": [ "v1", "4/5" ] }{ "id": 85125, "url": "