From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 9DBCBAFCA for ; Fri, 20 Jun 2014 12:24:59 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 20 Jun 2014 03:20:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,513,1400050800"; d="scan'208";a="550843106" Received: from shilc102.sh.intel.com ([10.239.39.44]) by fmsmga001.fm.intel.com with ESMTP; 20 Jun 2014 03:25:14 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shilc102.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s5KAPAMC029322; Fri, 20 Jun 2014 18:25:12 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s5KAP8AU006644; Fri, 20 Jun 2014 18:25:10 +0800 Received: (from jingche2@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id s5KAP8sv006640; Fri, 20 Jun 2014 18:25:08 +0800 From: "Chen Jing D(Mark)" To: dev@dpdk.org Date: Fri, 20 Jun 2014 18:24:43 +0800 Message-Id: <1403259884-6498-6-git-send-email-jing.d.chen@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1403259884-6498-1-git-send-email-jing.d.chen@intel.com> References: <1403259884-6498-1-git-send-email-jing.d.chen@intel.com> Subject: [dpdk-dev] [PATCH 5/6] i40e: PF host driver to support VF vlan offload and set pvid X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2014 10:25:00 -0000 From: "Chen Jing D(Mark)" PF driver add 2 commands, data structures and corresponding message handling functions to support VF doing VLAN offload and set/clear pvid operation. Signed-off-by: Chen Jing D(Mark) Acked-by: Helin Zhang Acked-by: Cunming Liang Acked-by: Jingjing Wu --- lib/librte_pmd_i40e/i40e_pf.c | 62 ++++++++++++++++++++++++++++++++++++++++- lib/librte_pmd_i40e/i40e_pf.h | 17 +++++++++++ 2 files changed, 78 insertions(+), 1 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_pf.c b/lib/librte_pmd_i40e/i40e_pf.c index 1fa65e9..e8b154d 100644 --- a/lib/librte_pmd_i40e/i40e_pf.c +++ b/lib/librte_pmd_i40e/i40e_pf.c @@ -304,7 +304,8 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf) goto send_msg; } - vf_res->vf_offload_flags = I40E_VIRTCHNL_VF_OFFLOAD_L2; + vf_res->vf_offload_flags = I40E_VIRTCHNL_VF_OFFLOAD_L2 | + I40E_VIRTCHNL_VF_OFFLOAD_VLAN; vf_res->max_vectors = hw->func_caps.num_msix_vectors_vf; vf_res->num_queue_pairs = vf->vsi->nb_qps; vf_res->num_vsis = I40E_DEFAULT_VF_VSI_NUM; @@ -356,6 +357,7 @@ i40e_pf_host_hmc_config_rxq(struct i40e_hw *hw, rx_ctx.tphhead_ena = 1; rx_ctx.lrxqthresh = 2; rx_ctx.crcstrip = 1; + rx_ctx.l2tsel = 1; rx_ctx.prefena = 1; err = i40e_clear_lan_rx_queue_context(hw, abs_queue_id); @@ -778,6 +780,56 @@ i40e_pf_host_process_cmd_get_link_status(struct i40e_pf_vf *vf) sizeof(struct rte_eth_link)); } +static int +i40e_pf_host_process_cmd_cfg_vlan_offload( + struct i40e_pf_vf *vf, + uint8_t *msg, + uint16_t msglen) +{ + int ret = I40E_SUCCESS; + struct i40e_virtchnl_vlan_offload_info *offload = + (struct i40e_virtchnl_vlan_offload_info *)msg; + + if (msg == NULL || msglen != sizeof(*offload)) { + ret = I40E_ERR_PARAM; + goto send_msg; + } + + ret = i40e_vsi_config_vlan_stripping(vf->vsi, + !!offload->enable_vlan_strip); + if (ret != 0) + PMD_DRV_LOG(ERR, "Failed to configure vlan stripping\n"); + +send_msg: + i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD, + ret, NULL, 0); + + return ret; +} + +static int +i40e_pf_host_process_cmd_cfg_pvid(struct i40e_pf_vf *vf, + uint8_t *msg, + uint16_t msglen) +{ + int ret = I40E_SUCCESS; + struct i40e_virtchnl_pvid_info *tpid_info = + (struct i40e_virtchnl_pvid_info *)msg; + + if (msg == NULL || msglen != sizeof(*tpid_info)) { + ret = I40E_ERR_PARAM; + goto send_msg; + } + + ret = i40e_vsi_vlan_pvid_set(vf->vsi, &tpid_info->info); + +send_msg: + i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_CFG_VLAN_PVID, + ret, NULL, 0); + + return ret; +} + void i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev, uint16_t abs_vf_id, uint32_t opcode, @@ -866,6 +918,14 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev, PMD_DRV_LOG(INFO, "OP_GET_LINK_STAT received\n"); i40e_pf_host_process_cmd_get_link_status(vf); break; + case I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD: + PMD_DRV_LOG(INFO, "OP_CFG_VLAN_OFFLOAD received\n"); + i40e_pf_host_process_cmd_cfg_vlan_offload(vf, msg, msglen); + break; + case I40E_VIRTCHNL_OP_CFG_VLAN_PVID: + PMD_DRV_LOG(INFO, "OP_CFG_VLAN_PVID received\n"); + i40e_pf_host_process_cmd_cfg_pvid(vf, msg, msglen); + break; /* Don't add command supported below, which will * return an error code. */ diff --git a/lib/librte_pmd_i40e/i40e_pf.h b/lib/librte_pmd_i40e/i40e_pf.h index ccbd0d8..41b6826 100644 --- a/lib/librte_pmd_i40e/i40e_pf.h +++ b/lib/librte_pmd_i40e/i40e_pf.h @@ -55,6 +55,23 @@ enum i40e_pf_vfr_state { enum i40e_virtchnl_ops_DPDK { /* Keep some gap between Linu PF commands and DPDK PF specific commands */ I40E_VIRTCHNL_OP_GET_LINK_STAT = I40E_VIRTCHNL_OP_EVENT + 0x100, + I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD, + I40E_VIRTCHNL_OP_CFG_VLAN_PVID, +}; +struct i40e_virtchnl_vlan_offload_info { + uint16_t vsi_id; + uint8_t enable_vlan_strip; + uint8_t reserved; +}; + +/* I40E_VIRTCHNL_OP_CFG_VLAN_PVID + * VF sends this message to enable/disable pvid. If it's enable op, needs to specify the + * pvid. + * PF returns status code in retval. + */ +struct i40e_virtchnl_pvid_info { + uint16_t vsi_id; + struct i40e_vsi_vlan_pvid_info info; }; int i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool do_hw_reset); -- 1.7.7.6