Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/808505/?format=api
{ "id": 808505, "url": "http://patchwork.ozlabs.org/api/patches/808505/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170901012625.14838-4-vinicius.gomes@intel.com/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170901012625.14838-4-vinicius.gomes@intel.com>", "list_archive_url": null, "date": "2017-09-01T01:26:23", "name": "[RFC,net-next,3/5] igb: Add support for CBS offload", "commit_ref": null, "pull_url": null, "state": "rfc", "archived": true, "hash": "64b69f121c17a4b6fbe516a13d8f37827473833e", "submitter": { "id": 72272, "url": "http://patchwork.ozlabs.org/api/people/72272/?format=api", "name": "Vinicius Costa Gomes", "email": "vinicius.gomes@intel.com" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/20170901012625.14838-4-vinicius.gomes@intel.com/mbox/", "series": [ { "id": 935, "url": "http://patchwork.ozlabs.org/api/series/935/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=935", "date": "2017-09-01T01:26:20", "name": "TSN: Add qdisc-based config interfaces for traffic shapers", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/935/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/808505/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/808505/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xk1mW12k1z9sMN\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 1 Sep 2017 11:26:35 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751318AbdIAB0c (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 31 Aug 2017 21:26:32 -0400", "from mga02.intel.com ([134.134.136.20]:20239 \"EHLO mga02.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751238AbdIAB0a (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tThu, 31 Aug 2017 21:26:30 -0400", "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t31 Aug 2017 18:26:29 -0700", "from ellie.jf.intel.com (HELO localhost.localdomain)\n\t([10.24.8.207])\n\tby fmsmga006.fm.intel.com with ESMTP; 31 Aug 2017 18:26:29 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.41,456,1498546800\"; d=\"scan'208\";a=\"146934280\"", "From": "Vinicius Costa Gomes <vinicius.gomes@intel.com>", "To": "netdev@vger.kernel.org", "Cc": "Andre Guedes <andre.guedes@intel.com>, jhs@mojatatu.com,\n\txiyou.wangcong@gmail.com, jiri@resnulli.us,\n\tintel-wired-lan@lists.osuosl.org, ivan.briano@intel.com,\n\tjesus.sanchez-palencia@intel.com, boon.leong.ong@intel.com,\n\trichardcochran@gmail.com", "Subject": "[RFC net-next 3/5] igb: Add support for CBS offload", "Date": "Thu, 31 Aug 2017 18:26:23 -0700", "Message-Id": "<20170901012625.14838-4-vinicius.gomes@intel.com>", "X-Mailer": "git-send-email 2.14.1", "In-Reply-To": "<20170901012625.14838-1-vinicius.gomes@intel.com>", "References": "<20170901012625.14838-1-vinicius.gomes@intel.com>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "From: Andre Guedes <andre.guedes@intel.com>\n\nThis patch adds support for Credit-Based Shaper (CBS) qdisc offload\nfrom Traffic Control system. This support enable us to leverage the\nForwarding and Queuing for Time-Sensitive Streams (FQTSS) features\nfrom Intel i210 Ethernet Controller. FQTSS is the former 802.1Qav\nstandard which was merged into 802.1Q in 2014. It enables traffic\nprioritization and bandwidth reservation via the Credit-Based Shaper\nwhich is implemented in hardware by i210 controller.\n\nThe patch introduces the igb_setup_tc() function which implements the\nsupport for CBS qdisc hardware offload in the IGB driver. CBS offload\nis the only traffic control offload supported by the driver at the\nmoment.\n\nFQTSS transmission mode from i210 controller is automatically enabled\nby the IGB driver when the CBS is enabled for the first hardware\nqueue. Likewise, FQTSS mode is automatically disabled when CBS is\ndisabled for the last hardware queue. Changing FQTSS mode requires NIC\nreset.\n\nFQTSS feature is supported by i210 controller only.\n\nSigned-off-by: Andre Guedes <andre.guedes@intel.com>\nSigned-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>\n---\n drivers/net/ethernet/intel/igb/e1000_defines.h | 23 ++\n drivers/net/ethernet/intel/igb/e1000_regs.h | 8 +\n drivers/net/ethernet/intel/igb/igb.h | 6 +\n drivers/net/ethernet/intel/igb/igb_main.c | 349 +++++++++++++++++++++++++\n 4 files changed, 386 insertions(+)", "diff": "diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h\nindex 1de82f247312..83cabff1e0ab 100644\n--- a/drivers/net/ethernet/intel/igb/e1000_defines.h\n+++ b/drivers/net/ethernet/intel/igb/e1000_defines.h\n@@ -353,7 +353,18 @@\n #define E1000_RXPBS_CFG_TS_EN 0x80000000\n \n #define I210_RXPBSIZE_DEFAULT\t\t0x000000A2 /* RXPBSIZE default */\n+#define I210_RXPBSIZE_MASK\t\t0x0000003F\n+#define I210_RXPBSIZE_PB_32KB\t\t0x00000020\n #define I210_TXPBSIZE_DEFAULT\t\t0x04000014 /* TXPBSIZE default */\n+#define I210_TXPBSIZE_MASK\t\t0xC0FFFFFF\n+#define I210_TXPBSIZE_PB0_8KB\t\t(8 << 0)\n+#define I210_TXPBSIZE_PB1_8KB\t\t(8 << 6)\n+#define I210_TXPBSIZE_PB2_4KB\t\t(4 << 12)\n+#define I210_TXPBSIZE_PB3_4KB\t\t(4 << 18)\n+\n+#define I210_DTXMXPKTSZ_DEFAULT\t\t0x00000098\n+\n+#define I210_SR_QUEUES_NUM\t\t2\n \n /* SerDes Control */\n #define E1000_SCTL_DISABLE_SERDES_LOOPBACK 0x0400\n@@ -1051,4 +1062,16 @@\n #define E1000_VLAPQF_P_VALID(_n)\t(0x1 << (3 + (_n) * 4))\n #define E1000_VLAPQF_QUEUE_MASK\t0x03\n \n+/* TX Qav Control fields */\n+#define E1000_TQAVCTRL_XMIT_MODE\tBIT(0)\n+#define E1000_TQAVCTRL_DATAFETCHARB\tBIT(4)\n+#define E1000_TQAVCTRL_DATATRANARB\tBIT(8)\n+\n+/* TX Qav Credit Control fields */\n+#define E1000_TQAVCC_IDLESLOPE_MASK\t0xFFFF\n+#define E1000_TQAVCC_QUEUEMODE\t\tBIT(31)\n+\n+/* Transmit Descriptor Control fields */\n+#define E1000_TXDCTL_PRIORITY\t\tBIT(27)\n+\n #endif\ndiff --git a/drivers/net/ethernet/intel/igb/e1000_regs.h b/drivers/net/ethernet/intel/igb/e1000_regs.h\nindex 58adbf234e07..8eee081d395f 100644\n--- a/drivers/net/ethernet/intel/igb/e1000_regs.h\n+++ b/drivers/net/ethernet/intel/igb/e1000_regs.h\n@@ -421,6 +421,14 @@ do { \\\n \n #define E1000_I210_FLA\t\t0x1201C\n \n+#define E1000_I210_DTXMXPKTSZ\t0x355C\n+\n+#define E1000_I210_TXDCTL(_n)\t(0x0E028 + ((_n) * 0x40))\n+\n+#define E1000_I210_TQAVCTRL\t0x3570\n+#define E1000_I210_TQAVCC(_n)\t(0x3004 + ((_n) * 0x40))\n+#define E1000_I210_TQAVHC(_n)\t(0x300C + ((_n) * 0x40))\n+\n #define E1000_INVM_DATA_REG(_n)\t(0x12120 + 4*(_n))\n #define E1000_INVM_SIZE\t\t64 /* Number of INVM Data Registers */\n \ndiff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h\nindex 06ffb2bc713e..92845692087a 100644\n--- a/drivers/net/ethernet/intel/igb/igb.h\n+++ b/drivers/net/ethernet/intel/igb/igb.h\n@@ -281,6 +281,11 @@ struct igb_ring {\n \tu16 count;\t\t\t/* number of desc. in the ring */\n \tu8 queue_index;\t\t\t/* logical index of the ring*/\n \tu8 reg_idx;\t\t\t/* physical index of the ring */\n+\tbool cbs_enable;\t\t/* indicates if CBS is enabled */\n+\ts32 idleslope;\t\t\t/* idleSlope in kbps */\n+\ts32 sendslope;\t\t\t/* sendSlope in kbps */\n+\ts32 hicredit;\t\t\t/* hiCredit in bytes */\n+\ts32 locredit;\t\t\t/* loCredit in bytes */\n \n \t/* everything past this point are written often */\n \tu16 next_to_clean;\n@@ -621,6 +626,7 @@ struct igb_adapter {\n #define IGB_FLAG_EEE\t\t\tBIT(14)\n #define IGB_FLAG_VLAN_PROMISC\t\tBIT(15)\n #define IGB_FLAG_RX_LEGACY\t\tBIT(16)\n+#define IGB_FLAG_FQTSS\t\t\tBIT(17)\n \n /* Media Auto Sense */\n #define IGB_MAS_ENABLE_0\t\t0X0001\ndiff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c\nindex fd4a46b03cc8..47cabca0c99a 100644\n--- a/drivers/net/ethernet/intel/igb/igb_main.c\n+++ b/drivers/net/ethernet/intel/igb/igb_main.c\n@@ -62,6 +62,17 @@\n #define BUILD 0\n #define DRV_VERSION __stringify(MAJ) \".\" __stringify(MIN) \".\" \\\n __stringify(BUILD) \"-k\"\n+\n+enum queue_mode {\n+\tQUEUE_MODE_STRICT_PRIORITY,\n+\tQUEUE_MODE_STREAM_RESERVATION,\n+};\n+\n+enum tx_queue_prio {\n+\tTX_QUEUE_PRIO_HIGH,\n+\tTX_QUEUE_PRIO_LOW,\n+};\n+\n char igb_driver_name[] = \"igb\";\n char igb_driver_version[] = DRV_VERSION;\n static const char igb_driver_string[] =\n@@ -1271,6 +1282,12 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter,\n \t\tring->count = adapter->tx_ring_count;\n \t\tring->queue_index = txr_idx;\n \n+\t\tring->cbs_enable = false;\n+\t\tring->idleslope = 0;\n+\t\tring->sendslope = 0;\n+\t\tring->hicredit = 0;\n+\t\tring->locredit = 0;\n+\n \t\tu64_stats_init(&ring->tx_syncp);\n \t\tu64_stats_init(&ring->tx_syncp2);\n \n@@ -1598,6 +1615,292 @@ static void igb_get_hw_control(struct igb_adapter *adapter)\n \t\t\tctrl_ext | E1000_CTRL_EXT_DRV_LOAD);\n }\n \n+static void enable_fqtss(struct igb_adapter *adapter, bool enable)\n+{\n+\tstruct net_device *netdev = adapter->netdev;\n+\n+\tif (enable)\n+\t\tadapter->flags |= IGB_FLAG_FQTSS;\n+\telse\n+\t\tadapter->flags &= ~IGB_FLAG_FQTSS;\n+\n+\tif (netif_running(netdev))\n+\t\tschedule_work(&adapter->reset_task);\n+\telse\n+\t\tigb_reset(adapter);\n+}\n+\n+static bool is_fqtss_enabled(struct igb_adapter *adapter)\n+{\n+\treturn (adapter->flags & IGB_FLAG_FQTSS) ? true : false;\n+}\n+\n+static int set_tx_desc_fetch_prio(struct e1000_hw *hw, int queue,\n+\t\t\t\t enum tx_queue_prio prio)\n+{\n+\tu32 val;\n+\n+\tWARN_ON(hw->mac.type != e1000_i210);\n+\n+\tif (queue < 0 || queue > 4)\n+\t\treturn -EINVAL;\n+\n+\tval = rd32(E1000_I210_TXDCTL(queue));\n+\n+\tif (prio == TX_QUEUE_PRIO_HIGH)\n+\t\tval |= E1000_TXDCTL_PRIORITY;\n+\telse\n+\t\tval &= ~E1000_TXDCTL_PRIORITY;\n+\n+\twr32(E1000_I210_TXDCTL(queue), val);\n+\treturn 0;\n+}\n+\n+static int set_queue_mode(struct e1000_hw *hw, int queue, enum queue_mode mode)\n+{\n+\tu32 val;\n+\n+\tWARN_ON(hw->mac.type != e1000_i210);\n+\n+\t/* Stream reservation is only supported for queue 0 and 1. */\n+\tif (queue < 0 || queue > 1)\n+\t\treturn -EINVAL;\n+\n+\tval = rd32(E1000_I210_TQAVCC(queue));\n+\n+\tif (mode == QUEUE_MODE_STREAM_RESERVATION)\n+\t\tval |= E1000_TQAVCC_QUEUEMODE;\n+\telse\n+\t\tval &= ~E1000_TQAVCC_QUEUEMODE;\n+\n+\twr32(E1000_I210_TQAVCC(queue), val);\n+\treturn 0;\n+}\n+\n+/**\n+ * igb_configure_cbs - Configure Credit-Based Shaper (CBS)\n+ * @adapter: pointer to adapter struct\n+ * @queue: queue number\n+ * @enable: true = enable CBS, false = disable CBS\n+ * @idleslope: idleSlope in kbps\n+ * @sendslope: sendSlope in kbps\n+ * @hicredit: hiCredit in bytes\n+ * @locredit: loCredit in bytes\n+ *\n+ * Configure CBS for a given hardware queue. When disabling, idleslope,\n+ * sendslope, hicredit, locredit arguments are ignored. Returns 0 if\n+ * success. Negative otherwise.\n+ **/\n+static void igb_configure_cbs(struct igb_adapter *adapter, int queue,\n+\t\t\t bool enable, int idleslope, int sendslope,\n+\t\t\t int hicredit, int locredit)\n+{\n+\tstruct net_device *netdev = adapter->netdev;\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tu32 tqavcc;\n+\tu16 value;\n+\n+\tWARN_ON(hw->mac.type != e1000_i210);\n+\tWARN_ON(queue < 0 || queue > 1);\n+\tWARN_ON(adapter->num_tx_queues < 2);\n+\n+\tif (enable) {\n+\t\tset_tx_desc_fetch_prio(hw, queue, TX_QUEUE_PRIO_HIGH);\n+\t\tset_queue_mode(hw, queue, QUEUE_MODE_STREAM_RESERVATION);\n+\n+\t\t/* According to i210 datasheet section 7.2.7.7, we should set\n+\t\t * the 'idleSlope' field from TQAVCC register following the\n+\t\t * equation:\n+\t\t *\n+\t\t * For 100 Mbps link speed:\n+\t\t *\n+\t\t * value = BW * 0x7735 * 0.2 (E1)\n+\t\t *\n+\t\t * For 1000Mbps link speed:\n+\t\t *\n+\t\t * value = BW * 0x7735 * 2 (E2)\n+\t\t *\n+\t\t * E1 and E2 can be merged into one equation as shown below.\n+\t\t * Note that 'link-speed' is in Mbps.\n+\t\t *\n+\t\t * value = BW * 0x7735 * 2 * link-speed\n+\t\t * -------------- (E3)\n+\t\t * 1000\n+\t\t *\n+\t\t * 'BW' is the percentage bandwidth out of full link speed\n+\t\t * which can be found with the following equation. Note that\n+\t\t * idleSlope here is the parameter from this function which\n+\t\t * is in kbps.\n+\t\t *\n+\t\t * BW = idleSlope\n+\t\t * ----------------- (E4)\n+\t\t * link-speed * 1000\n+\t\t *\n+\t\t * That said, we can come up with a generic equation to\n+\t\t * calculate the value we should set it TQAVCC register by\n+\t\t * replacing 'BW' in E3 by E4. The resulting equation is:\n+\t\t *\n+\t\t * value = idleSlope * 0x7735 * 2 * link-speed\n+\t\t * ----------------- -------------- (E5)\n+\t\t * link-speed * 1000 1000\n+\t\t *\n+\t\t * 'link-speed' is present in both sides of the fraction so\n+\t\t * it is canceled out. The final equation is the following:\n+\t\t *\n+\t\t * value = idleSlope * 61034\n+\t\t * ----------------- (E6)\n+\t\t * 1000000\n+\t\t */\n+\t\tvalue = DIV_ROUND_UP_ULL(idleslope * 61034ULL, 1000000);\n+\n+\t\ttqavcc = rd32(E1000_I210_TQAVCC(queue));\n+\t\ttqavcc &= ~E1000_TQAVCC_IDLESLOPE_MASK;\n+\t\ttqavcc |= value;\n+\t\twr32(E1000_I210_TQAVCC(queue), tqavcc);\n+\n+\t\twr32(E1000_I210_TQAVHC(queue), 0x80000000 + hicredit * 0x7735);\n+\t} else {\n+\t\tset_tx_desc_fetch_prio(hw, queue, TX_QUEUE_PRIO_LOW);\n+\t\tset_queue_mode(hw, queue, QUEUE_MODE_STRICT_PRIORITY);\n+\n+\t\t/* Set idleSlope to zero. */\n+\t\ttqavcc = rd32(E1000_I210_TQAVCC(queue));\n+\t\ttqavcc &= ~E1000_TQAVCC_IDLESLOPE_MASK;\n+\t\twr32(E1000_I210_TQAVCC(queue), tqavcc);\n+\n+\t\t/* Set hiCredit to zero. */\n+\t\twr32(E1000_I210_TQAVHC(queue), 0);\n+\t}\n+\n+\t/* XXX: In i210 controller the sendSlope and loCredit\n+\t * parameters from CBS are not configurable by software so we\n+\t * don't do any 'controller configuration' in respect to these\n+\t * parameters.\n+\t */\n+\n+\tnetdev_dbg(netdev, \"CBS %s: queue %d idleslope %d sendslope %d \"\n+\t\t \"hiCredit %d locredit %d\\n\",\n+\t\t (enable) ? \"enabled\" : \"disabled\", queue,\n+\t\t idleslope, sendslope, hicredit, locredit);\n+}\n+\n+static void igb_save_cbs_params(struct igb_adapter *adapter, int queue,\n+\t\t\t\tbool enable, int idleslope, int sendslope,\n+\t\t\t\tint hicredit, int locredit)\n+{\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tstruct igb_ring *ring;\n+\n+\tWARN_ON(hw->mac.type != e1000_i210);\n+\tWARN_ON(queue < 0 || queue > 1);\n+\tWARN_ON(adapter->num_tx_queues < 2);\n+\n+\tring = adapter->tx_ring[queue];\n+\n+\tring->cbs_enable = enable;\n+\tring->idleslope = idleslope;\n+\tring->sendslope = sendslope;\n+\tring->hicredit = hicredit;\n+\tring->locredit = locredit;\n+}\n+\n+static bool is_any_cbs_enabled(struct igb_adapter *adapter)\n+{\n+\tstruct igb_ring *ring;\n+\tint i;\n+\n+\tWARN_ON(adapter->num_tx_queues < 2);\n+\n+\tfor (i = 0; i < I210_SR_QUEUES_NUM; i++) {\n+\t\tring = adapter->tx_ring[i];\n+\n+\t\tif (ring->cbs_enable)\n+\t\t\treturn true;\n+\t}\n+\n+\treturn false;\n+}\n+\n+static void igb_setup_tx_mode(struct igb_adapter *adapter)\n+{\n+\tstruct net_device *netdev = adapter->netdev;\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tu32 val;\n+\tint i;\n+\n+\t/* Only i210 controller supports changing the transmission mode. */\n+\tif (hw->mac.type != e1000_i210)\n+\t\treturn;\n+\n+\tif (is_fqtss_enabled(adapter)) {\n+\t\t/* Configure TQAVCTRL register: set transmit mode to 'Qav',\n+\t\t * set data fetch arbitration to 'round robin' and set data\n+\t\t * transfer arbitration to 'credit shaper algorithm.\n+\t\t */\n+\t\tval = rd32(E1000_I210_TQAVCTRL);\n+\t\tval |= E1000_TQAVCTRL_XMIT_MODE | E1000_TQAVCTRL_DATATRANARB;\n+\t\tval &= ~E1000_TQAVCTRL_DATAFETCHARB;\n+\t\twr32(E1000_I210_TQAVCTRL, val);\n+\n+\t\t/* Configure Tx and Rx packet buffers sizes as described in\n+\t\t * i210 datasheet section 7.2.7.7.\n+\t\t */\n+\t\tval = rd32(E1000_TXPBS);\n+\t\tval &= ~I210_TXPBSIZE_MASK;\n+\t\tval |= I210_TXPBSIZE_PB0_8KB | I210_TXPBSIZE_PB1_8KB |\n+\t\t\tI210_TXPBSIZE_PB2_4KB | I210_TXPBSIZE_PB3_4KB;\n+\t\twr32(E1000_TXPBS, val);\n+\n+\t\tval = rd32(E1000_RXPBS);\n+\t\tval &= ~I210_RXPBSIZE_MASK;\n+\t\tval |= I210_RXPBSIZE_PB_32KB;\n+\t\twr32(E1000_RXPBS, val);\n+\n+\t\t/* Section 8.12.9 states that MAX_TPKT_SIZE from DTXMXPKTSZ\n+\t\t * register should not exceed the buffer size programmed in\n+\t\t * TXPBS. The smallest buffer size programmed in TXPBS is 4kB\n+\t\t * so according to the datasheet we should set MAX_TPKT_SIZE to\n+\t\t * 4kB / 64.\n+\t\t *\n+\t\t * However, when we do so, no frame from queue 2 and 3 are\n+\t\t * transmitted. It seems the MAX_TPKT_SIZE should not be great\n+\t\t * or _equal_ to the buffer size programmed in TXPBS. For this\n+\t\t * reason, we set set MAX_ TPKT_SIZE to (4kB - 1) / 64.\n+\t\t */\n+\t\tval = (4096 - 1) / 64;\n+\t\twr32(E1000_I210_DTXMXPKTSZ, val);\n+\n+\t\t/* Since FQTSS mode is enabled, apply any CBS configuration\n+\t\t * previously set. If no previous CBS configuration has been\n+\t\t * done, then the initial configuration is applied, which means\n+\t\t * CBS is disabled. CBS configuration is only supported by SR\n+\t\t * queues i.e. queue 0 and queue 1.\n+\t\t */\n+\t\tfor (i = 0; i < I210_SR_QUEUES_NUM; i++) {\n+\t\t\tstruct igb_ring *ring = adapter->tx_ring[i];\n+\n+\t\t\tigb_configure_cbs(adapter, i, ring->cbs_enable,\n+\t\t\t\t\t ring->idleslope, ring->sendslope,\n+\t\t\t\t\t ring->hicredit, ring->locredit);\n+\t\t}\n+\t} else {\n+\t\twr32(E1000_RXPBS, I210_RXPBSIZE_DEFAULT);\n+\t\twr32(E1000_TXPBS, I210_TXPBSIZE_DEFAULT);\n+\t\twr32(E1000_I210_DTXMXPKTSZ, I210_DTXMXPKTSZ_DEFAULT);\n+\n+\t\tval = rd32(E1000_I210_TQAVCTRL);\n+\t\t/* According to Section 8.12.21, the other flags we've set when\n+\t\t * enabling FQTSS are not relevant when disabling FQTSS so we\n+\t\t * don't set they here.\n+\t\t */\n+\t\tval &= ~E1000_TQAVCTRL_XMIT_MODE;\n+\t\twr32(E1000_I210_TQAVCTRL, val);\n+\t}\n+\n+\tnetdev_dbg(netdev, \"FQTSS %s\\n\", (is_fqtss_enabled(adapter)) ?\n+\t\t \"enabled\" : \"disabled\");\n+}\n+\n /**\n * igb_configure - configure the hardware for RX and TX\n * @adapter: private board structure\n@@ -1609,6 +1912,7 @@ static void igb_configure(struct igb_adapter *adapter)\n \n \tigb_get_hw_control(adapter);\n \tigb_set_rx_mode(netdev);\n+\tigb_setup_tx_mode(adapter);\n \n \tigb_restore_vlan(adapter);\n \n@@ -2150,6 +2454,50 @@ igb_features_check(struct sk_buff *skb, struct net_device *dev,\n \treturn features;\n }\n \n+static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type,\n+\t\t\tvoid *type_data)\n+{\n+\tstruct igb_adapter *adapter = netdev_priv(dev);\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tstruct tc_cbs_qopt_offload *cbs;\n+\n+\tif (hw->mac.type != e1000_i210)\n+\t\treturn -ENOTSUPP;\n+\n+\tif (type != TC_SETUP_CBS)\n+\t\treturn -ENOTSUPP;\n+\n+\t/* In order to support FQTSS feature, we must have at least 2 Tx\n+\t * queues enabled.\n+\t */\n+\tif (adapter->num_tx_queues < 2)\n+\t\treturn -ENOTSUPP;\n+\n+\tcbs = type_data;\n+\n+\t/* Only queues 0 and 1 support CBS configuration. */\n+\tif (cbs->queue < 0 || cbs->queue > 1)\n+\t\treturn -EINVAL;\n+\n+\tigb_save_cbs_params(adapter, cbs->queue, cbs->enable,\n+\t\t\t cbs->idleslope, cbs->sendslope,\n+\t\t\t cbs->hicredit, cbs->locredit);\n+\n+\tif (is_fqtss_enabled(adapter)) {\n+\t\tigb_configure_cbs(adapter, cbs->queue, cbs->enable,\n+\t\t\t\t cbs->idleslope, cbs->sendslope,\n+\t\t\t\t cbs->hicredit, cbs->locredit);\n+\n+\t\tif (!is_any_cbs_enabled(adapter))\n+\t\t\tenable_fqtss(adapter, false);\n+\n+\t} else {\n+\t\tenable_fqtss(adapter, true);\n+\t}\n+\n+\treturn 0;\n+}\n+\n static const struct net_device_ops igb_netdev_ops = {\n \t.ndo_open\t\t= igb_open,\n \t.ndo_stop\t\t= igb_close,\n@@ -2175,6 +2523,7 @@ static const struct net_device_ops igb_netdev_ops = {\n \t.ndo_set_features\t= igb_set_features,\n \t.ndo_fdb_add\t\t= igb_ndo_fdb_add,\n \t.ndo_features_check\t= igb_features_check,\n+\t.ndo_setup_tc\t\t= igb_setup_tc,\n };\n \n /**\n", "prefixes": [ "RFC", "net-next", "3/5" ] }