Show a patch.

GET /api/patches/363/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 363,
    "url": "http://patches.dpdk.org/api/patches/363/",
    "web_url": "http://patches.dpdk.org/patch/363/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<1410503639-10753-3-git-send-email-jijiang.liu@intel.com>",
    "date": "2014-09-12T06:33:53",
    "name": "[dpdk-dev,v3,2/8] i40e:support VxLAN packet identification in librte_pmd_i40e",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8e6c28170d83d235367507757acf81f5a3d8f3c5",
    "submitter": {
        "id": 52,
        "url": "http://patches.dpdk.org/api/people/52/",
        "name": "Jijiang Liu",
        "email": "jijiang.liu@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/patch/363/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/363/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/363/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "References": "<1410503639-10753-1-git-send-email-jijiang.liu@intel.com>",
        "X-Mailman-Version": "2.1.15",
        "X-IronPort-AV": "E=Sophos;i=\"4.97,862,1389772800\"; d=\"scan'208\";a=\"385121514\"",
        "Date": "Fri, 12 Sep 2014 14:33:53 +0800",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<1410503639-10753-3-git-send-email-jijiang.liu@intel.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id DF2C6B396;\n\tFri, 12 Sep 2014 08:28:56 +0200 (CEST)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id D9608B396\n\tfor <dev@dpdk.org>; Fri, 12 Sep 2014 08:28:53 +0200 (CEST)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga101.fm.intel.com with ESMTP; 11 Sep 2014 23:34:10 -0700",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2014 23:28:59 -0700",
            "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id s8C6Y7Vk005974;\n\tFri, 12 Sep 2014 14:34:07 +0800",
            "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid s8C6Y5px010802; Fri, 12 Sep 2014 14:34:07 +0800",
            "(from jijiangl@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s8C6Y5a0010798; \n\tFri, 12 Sep 2014 14:34:05 +0800"
        ],
        "List-Post": "<mailto:dev@dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH v3 2/8]i40e:support VxLAN packet identification\n\tin librte_pmd_i40e",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "Precedence": "list",
        "From": "Jijiang Liu <jijiang.liu@intel.com>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "X-ExtLoop1": "1",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "Delivered-To": "patchwork@dpdk.org",
        "In-Reply-To": "<1410503639-10753-1-git-send-email-jijiang.liu@intel.com>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "To": "dev@dpdk.org",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Support tunneling UDP port configuration on i40e in librte_pmd_i40e.\nCurrently, only VxLAN is implemented, which include\n -  VxLAN UDP port initialization\n -  Implement the APIs to configure VxLAN UDP port in librte_pmd_i40e.\n\nSigned-off-by: Jijiang Liu <jijiang.liu@intel.com>\nAcked-by: Helin Zhang <helin.zhang@intel.com>\nAcked-by: Jingjing Wu <jingjing.wu@intel.com>\nAcked-by: Jing Chen <jing.d.chen@intel.com>\n \n---\n config/common_linuxapp            |    5 +\n lib/librte_mbuf/rte_mbuf.h        |    2 +\n lib/librte_pmd_i40e/i40e_ethdev.c |  200 ++++++++++++++++++++++++++++++++++++-\n lib/librte_pmd_i40e/i40e_ethdev.h |    5 +\n lib/librte_pmd_i40e/i40e_rxtx.c   |   11 ++\n 5 files changed, 222 insertions(+), 1 deletions(-)",
    "diff": "diff --git a/config/common_linuxapp b/config/common_linuxapp\nindex 9047975..b5ecf15 100644\n--- a/config/common_linuxapp\n+++ b/config/common_linuxapp\n@@ -212,6 +212,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4\n CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1\n \n #\n+# Compile tunneling UDP port support\n+#\n+CONFIG_RTE_LIBRTE_TUNNEL_UDP_PORT=4789\n+\n+#\n # Compile burst-oriented VIRTIO PMD driver\n #\n CONFIG_RTE_LIBRTE_VIRTIO_PMD=y\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 2735f37..1832e73 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -594,6 +594,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)\n \tm->pkt.in_port = 0xff;\n \n \tm->ol_flags = 0;\n+\tm->reserved = 0;\n \tbuf_ofs = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ?\n \t\t\tRTE_PKTMBUF_HEADROOM : m->buf_len;\n \tm->pkt.data = (char*) m->buf_addr + buf_ofs;\n@@ -658,6 +659,7 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *md)\n \tmi->pkt.pkt_len = mi->pkt.data_len;\n \tmi->pkt.nb_segs = 1;\n \tmi->ol_flags = md->ol_flags;\n+\tmi->reserved = md->reserved;\n \n \t__rte_mbuf_sanity_check(mi, RTE_MBUF_PKT, 1);\n \t__rte_mbuf_sanity_check(md, RTE_MBUF_PKT, 0);\ndiff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c\nindex 4e65ca4..4234073 100644\n--- a/lib/librte_pmd_i40e/i40e_ethdev.c\n+++ b/lib/librte_pmd_i40e/i40e_ethdev.c\n@@ -189,7 +189,7 @@ static int i40e_res_pool_alloc(struct i40e_res_pool_info *pool,\n static int i40e_dev_init_vlan(struct rte_eth_dev *dev);\n static int i40e_veb_release(struct i40e_veb *veb);\n static struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf,\n-\t\t\t\t\t\tstruct i40e_vsi *vsi);\n+\t\t\t\t\tstruct i40e_vsi *vsi);\n static int i40e_pf_config_mq_rx(struct i40e_pf *pf);\n static int i40e_vsi_config_double_vlan(struct i40e_vsi *vsi, int on);\n static inline int i40e_find_all_vlan_for_mac(struct i40e_vsi *vsi,\n@@ -205,6 +205,14 @@ static int i40e_dev_rss_hash_update(struct rte_eth_dev *dev,\n \t\t\t\t    struct rte_eth_rss_conf *rss_conf);\n static int i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,\n \t\t\t\t      struct rte_eth_rss_conf *rss_conf);\n+static int i40e_dev_udp_tunnel_add(struct rte_eth_dev *dev,\n+\t\t\t\t   struct rte_eth_udp_tunnel *udp_tunnel,\n+\t\t\t\t   uint8_t count);\n+static int i40e_dev_udp_tunnel_del(struct rte_eth_dev *dev,\n+\t\t\t\t   struct rte_eth_udp_tunnel *udp_tunnel,\n+\t\t\t\t   uint8_t count);\n+static int i40e_pf_config_vxlan(struct i40e_pf *pf);\n+\n \n /* Default hash key buffer for RSS */\n static uint32_t rss_key_default[I40E_PFQF_HKEY_MAX_INDEX + 1];\n@@ -256,6 +264,8 @@ static struct eth_dev_ops i40e_eth_dev_ops = {\n \t.reta_query                   = i40e_dev_rss_reta_query,\n \t.rss_hash_update              = i40e_dev_rss_hash_update,\n \t.rss_hash_conf_get            = i40e_dev_rss_hash_conf_get,\n+\t.udp_tunnel_add               = i40e_dev_udp_tunnel_add,\n+\t.udp_tunnel_del               = i40e_dev_udp_tunnel_del,\n };\n \n static struct eth_driver rte_i40e_pmd = {\n@@ -2529,6 +2539,34 @@ i40e_vsi_dump_bw_config(struct i40e_vsi *vsi)\n \treturn 0;\n }\n \n+static int\n+i40e_vxlan_filters_init(struct i40e_pf *pf)\n+{\n+\tuint8_t filter_index;\n+\tint ret = 0;\n+\tstruct i40e_hw *hw = I40E_PF_TO_HW(pf);\n+\n+\tif (!(pf->flags & I40E_FLAG_VXLAN))\n+\t\treturn 0;\n+\n+\t/* Init first entry in tunneling UDP table */\n+\tret = i40e_aq_add_udp_tunnel(hw, RTE_LIBRTE_TUNNEL_UDP_PORT,\n+\t\t\t\tI40E_AQC_TUNNEL_TYPE_VXLAN,\n+\t\t\t\t&filter_index, NULL);\n+\tif (ret < 0) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to add UDP tunnel port %d \"\n+\t\t\t\"with index=%d\\n\", RTE_VXLAN_UDP_PORT,\n+\t\t\t filter_index);\n+\t} else {\n+\t\tpf->vxlan_bitmap |= 1;\n+\t\tpf->vxlan_ports[0] = RTE_LIBRTE_TUNNEL_UDP_PORT;\n+\t\tPMD_DRV_LOG(INFO, \"Added UDP tunnel port %d with \"\n+\t\t\t\"index=%d\\n\", RTE_VXLAN_UDP_PORT, filter_index);\n+\t}\n+\n+\treturn ret;\n+}\n+\n /* Setup a VSI */\n struct i40e_vsi *\n i40e_vsi_setup(struct i40e_pf *pf,\n@@ -3160,6 +3198,12 @@ i40e_vsi_rx_init(struct i40e_vsi *vsi)\n \tuint16_t i;\n \n \ti40e_pf_config_mq_rx(pf);\n+\n+\tif (data->dev_conf.tunnel_type == RTE_TUNNEL_TYPE_VXLAN) {\n+\t\tpf->flags |= I40E_FLAG_VXLAN;\n+\t\ti40e_pf_config_vxlan(pf);\n+\t}\n+\n \tfor (i = 0; i < data->nb_rx_queues; i++) {\n \t\tret = i40e_rx_queue_init(data->rx_queues[i]);\n \t\tif (ret != I40E_SUCCESS) {\n@@ -4076,6 +4120,150 @@ i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,\n \treturn 0;\n }\n \n+static int\n+i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)\n+{\n+\tuint8_t i;\n+\n+\tfor (i = 0; i < I40E_MAX_PF_UDP_OFFLOAD_PORTS; i++) {\n+\t\tif (pf->vxlan_ports[i] == port)\n+\t\t\treturn i;\n+\t}\n+\n+\treturn -1;\n+}\n+\n+static int\n+i40e_add_vxlan_port(struct i40e_pf *pf, uint16_t port)\n+{\n+\tint  idx, ret;\n+\tuint8_t filter_idx;\n+\tstruct i40e_hw *hw = I40E_PF_TO_HW(pf);\n+\n+\tif (!(pf->flags & I40E_FLAG_VXLAN)) {\n+\t\tPMD_DRV_LOG(ERR, \"VxLAN tunneling mode is not configured\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tidx = i40e_get_vxlan_port_idx(pf, port);\n+\n+\t/* Check if port already exists */\n+\tif (idx >= 0) {\n+\t\tPMD_DRV_LOG(ERR, \"Port %d already offloaded\\n\", port);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Now check if there is space to add the new port */\n+\tidx = i40e_get_vxlan_port_idx(pf, 0);\n+\tif (idx < 0) {\n+\t\tPMD_DRV_LOG(ERR, \"Maximum number of UDP ports reached,\"\n+\t\t\t\"not adding port %d\\n\", port);\n+\t\treturn -ENOSPC;\n+\t}\n+\n+\tret =  i40e_aq_add_udp_tunnel(hw, port, I40E_AQC_TUNNEL_TYPE_VXLAN,\n+\t\t\t\t\t&filter_idx, NULL);\n+\tif (ret < 0) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to add VxLAN UDP port %d\\n\", port);\n+\t\treturn -1;\n+\t}\n+\n+\tPMD_DRV_LOG(INFO, \"Added %s port %d with AQ command with index %d\\n\",\n+\t\t\t port,  filter_index);\n+\n+\t/* New port: add it and mark its index in the bitmap */\n+\tpf->vxlan_ports[idx] = port;\n+\tpf->vxlan_bitmap |= (1 << idx);\n+\n+\treturn 0;\n+}\n+\n+static int\n+i40e_del_vxlan_port(struct i40e_pf *pf, uint16_t port)\n+{\n+\tint idx;\n+\tstruct i40e_hw *hw = I40E_PF_TO_HW(pf);\n+\n+\tidx = i40e_get_vxlan_port_idx(pf, port);\n+\n+\tif (idx < 0) {\n+\t\tPMD_DRV_LOG(ERR, \"Port %d doesn't exist\\n\", port);\n+\t\treturn -1;\n+\t}\n+\n+\tif (i40e_aq_del_udp_tunnel(hw, idx, NULL) < 0) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to delete VxLAN UDP port %d\\n\", port);\n+\t\treturn -1;\n+\t}\n+\n+\tPMD_DRV_LOG(INFO, \"Added port %d with AQ command with index %d\\n\",\n+\t\t\tport, idx);\n+\n+\tpf->vxlan_ports[idx] = 0;\n+\tpf->vxlan_bitmap &= ~(1 << idx);\n+\n+\treturn 0;\n+}\n+\n+/* configure port of UDP tunneling */\n+static int\n+i40e_dev_udp_tunnel_add(struct rte_eth_dev *dev,\n+\t\tstruct rte_eth_udp_tunnel *udp_tunnel, uint8_t count)\n+{\n+\tuint16_t i;\n+\tint ret = 0;\n+\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\n+\tfor (i = 0; i < count; i++, udp_tunnel++) {\n+\t\tswitch (udp_tunnel->prot_type) {\n+\t\tcase RTE_TUNNEL_TYPE_VXLAN:\n+\t\t\tret = i40e_add_vxlan_port(pf, udp_tunnel->udp_port);\n+\t\t\tbreak;\n+\n+\t\tcase RTE_TUNNEL_TYPE_GENEVE:\n+\t\tcase RTE_TUNNEL_TYPE_TEREDO:\n+\t\t\tPMD_DRV_LOG(ERR, \"Tunnel type is not supported now.\\n\");\n+\t\t\tret = -1;\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tPMD_DRV_LOG(ERR, \"Invalid tunnel type\\n\");\n+\t\t\tret = -1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\treturn ret;\n+}\n+\n+static int\n+i40e_dev_udp_tunnel_del(struct rte_eth_dev *dev,\n+\t\t\tstruct rte_eth_udp_tunnel *udp_tunnel, uint8_t count)\n+{\n+\tuint16_t i;\n+\tint ret = 0;\n+\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\n+\tfor (i = 0; i < count; i++, udp_tunnel++) {\n+\t\tswitch (udp_tunnel->prot_type) {\n+\t\tcase RTE_TUNNEL_TYPE_VXLAN:\n+\t\t\tret = i40e_del_vxlan_port(pf, udp_tunnel->udp_port);\n+\t\t\tbreak;\n+\t\tcase RTE_TUNNEL_TYPE_GENEVE:\n+\t\tcase RTE_TUNNEL_TYPE_TEREDO:\n+\t\t\tPMD_DRV_LOG(ERR, \"Tunnel type is not supported now.\\n\");\n+\t\t\tret = -1;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tPMD_DRV_LOG(ERR, \"Invalid tunnel type\\n\");\n+\t\t\tret = -1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\treturn ret;\n+}\n+\n /* Configure RSS */\n static int\n i40e_pf_config_rss(struct i40e_pf *pf)\n@@ -4112,6 +4300,16 @@ i40e_pf_config_rss(struct i40e_pf *pf)\n \treturn i40e_hw_rss_hash_set(hw, &rss_conf);\n }\n \n+/* Configure VxLAN */\n+static int\n+i40e_pf_config_vxlan(struct i40e_pf *pf)\n+{\n+\tif (pf->flags & I40E_FLAG_VXLAN)\n+\t\ti40e_vxlan_filters_init(pf);\n+\n+\treturn 0;\n+}\n+\n static int\n i40e_pf_config_mq_rx(struct i40e_pf *pf)\n {\ndiff --git a/lib/librte_pmd_i40e/i40e_ethdev.h b/lib/librte_pmd_i40e/i40e_ethdev.h\nindex 64deef2..22d0628 100644\n--- a/lib/librte_pmd_i40e/i40e_ethdev.h\n+++ b/lib/librte_pmd_i40e/i40e_ethdev.h\n@@ -60,6 +60,7 @@\n #define I40E_FLAG_HEADER_SPLIT_DISABLED (1ULL << 4)\n #define I40E_FLAG_HEADER_SPLIT_ENABLED  (1ULL << 5)\n #define I40E_FLAG_FDIR                  (1ULL << 6)\n+#define I40E_FLAG_VXLAN                 (1ULL << 7)\n #define I40E_FLAG_ALL (I40E_FLAG_RSS | \\\n \t\t       I40E_FLAG_DCB | \\\n \t\t       I40E_FLAG_VMDQ | \\\n@@ -216,6 +217,10 @@ struct i40e_pf {\n \tuint16_t vmdq_nb_qps; /* The number of queue pairs of VMDq */\n \tuint16_t vf_nb_qps; /* The number of queue pairs of VF */\n \tuint16_t fdir_nb_qps; /* The number of queue pairs of Flow Director */\n+\n+\t/* store VxLAN UDP ports */\n+\tuint16_t vxlan_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];\n+\tuint16_t vxlan_bitmap; /* Vxlan bit mask */\n };\n \n enum pending_msg {\ndiff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c\nindex f153844..a1dce74 100644\n--- a/lib/librte_pmd_i40e/i40e_rxtx.c\n+++ b/lib/librte_pmd_i40e/i40e_rxtx.c\n@@ -611,6 +611,12 @@ i40e_rx_scan_hw_ring(struct i40e_rx_queue *rxq)\n \t\t\t\t\t\tI40E_RXD_QW1_STATUS_SHIFT;\n \t\t\tpkt_len = ((qword1 & I40E_RXD_QW1_LENGTH_PBUF_MASK) >>\n \t\t\t\tI40E_RXD_QW1_LENGTH_PBUF_SHIFT) - rxq->crc_len;\n+\n+\t\t\t/* reserved is used to store packet type for RX side */\n+\t\t\tmb->reserved = (uint8_t)((qword1 &\n+\t\t\t\t\tI40E_RXD_QW1_PTYPE_MASK) >>\n+\t\t\t\t\tI40E_RXD_QW1_PTYPE_SHIFT);\n+\n \t\t\tmb->pkt.data_len = pkt_len;\n \t\t\tmb->pkt.pkt_len = pkt_len;\n \t\t\tmb->pkt.vlan_macip.f.vlan_tci = rx_status &\n@@ -857,6 +863,8 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)\n \t\tpkt_flags = i40e_rxd_status_to_pkt_flags(qword1);\n \t\tpkt_flags |= i40e_rxd_error_to_pkt_flags(qword1);\n \t\tpkt_flags |= i40e_rxd_ptype_to_pkt_flags(qword1);\n+\t\trxm->reserved = (uint8_t)((qword1 & I40E_RXD_QW1_PTYPE_MASK) >>\n+\t\t\t\tI40E_RXD_QW1_PTYPE_SHIFT);\n \t\trxm->ol_flags = pkt_flags;\n \t\tif (pkt_flags & PKT_RX_RSS_HASH)\n \t\t\trxm->pkt.hash.rss =\n@@ -1010,6 +1018,9 @@ i40e_recv_scattered_pkts(void *rx_queue,\n \t\tpkt_flags = i40e_rxd_status_to_pkt_flags(qword1);\n \t\tpkt_flags |= i40e_rxd_error_to_pkt_flags(qword1);\n \t\tpkt_flags |= i40e_rxd_ptype_to_pkt_flags(qword1);\n+\t\tfirst_seg->reserved = (uint8_t)((qword1 &\n+\t\t\t\t\tI40E_RXD_QW1_PTYPE_MASK) >>\n+\t\t\t\t\tI40E_RXD_QW1_PTYPE_SHIFT);\n \t\tfirst_seg->ol_flags = pkt_flags;\n \t\tif (pkt_flags & PKT_RX_RSS_HASH)\n \t\t\trxm->pkt.hash.rss =\n",
    "prefixes": [
        "dpdk-dev",
        "v3",
        "2/8"
    ]
}