From patchwork Fri Sep 25 08:44:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingjing Wu X-Patchwork-Id: 7186 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 9D4CD8E56; Fri, 25 Sep 2015 10:44:49 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 0AC71CF9 for ; Fri, 25 Sep 2015 10:44:47 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 25 Sep 2015 01:44:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,585,1437462000"; d="scan'208";a="652050904" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 25 Sep 2015 01:44:47 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t8P8ihLt022640; Fri, 25 Sep 2015 16:44:43 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t8P8ieni007283; Fri, 25 Sep 2015 16:44:42 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t8P8ie56007279; Fri, 25 Sep 2015 16:44:40 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Fri, 25 Sep 2015 16:44:38 +0800 Message-Id: <1443170678-7249-1-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 Cc: yulong.pei@intel.com Subject: [dpdk-dev] [PATCH] i40e: workaround for Security issue in SR-IOV mode 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In SR-IOV mode a VF sending LFC or PFC would throttle the entire port. The workaround is to add a filter to drop pause frames from VFs from sending pause frames. Signed-off-by: Jingjing Wu --- drivers/net/i40e/i40e_ethdev.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 2dd9fdc..6cc2172 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -382,6 +382,30 @@ static inline void i40e_flex_payload_reg_init(struct i40e_hw *hw) I40E_WRITE_REG(hw, I40E_GLQF_PIT(17), 0x00007440); } +#define I40E_FLOW_CONTROL_ETHERTYPE 0x8808 + +/* + * Add a ethertype filter to drop all flow control frames transimited + * from VSIs. +*/ +static void +i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf) +{ + struct i40e_hw *hw = I40E_PF_TO_HW(pf); + uint16_t flags = I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC | + I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP | + I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX; + int ret; + + ret = i40e_aq_add_rem_control_packet_filter(hw, NULL, + I40E_FLOW_CONTROL_ETHERTYPE, flags, + pf->main_vsi_seid, 0, + TRUE, NULL, NULL); + if (ret) + PMD_INIT_LOG(ERR, "Failed to add filter to drop flow control " + " frames from VSIs."); +} + static int eth_i40e_dev_init(struct rte_eth_dev *dev) { @@ -584,6 +608,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev) /* enable uio intr after callback register */ rte_intr_enable(&(pci_dev->intr_handle)); + /* + * Add a ethertype filter to drop all flow control frames transimited + * from VSIs. This is used to workaround the issue -- in SR-IOV mode + * where a VF sending LFC or PFC would throttle the entire port. + */ + i40e_add_tx_flow_control_drop_filter(pf); /* initialize mirror rule list */ TAILQ_INIT(&pf->mirror_list);