get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 74797,
    "url": "http://patches.dpdk.org/api/patches/74797/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/dee5d56c6d6e30e4a77b7d62781e0995a727045d.1595648149.git.cloud.wangxiaoyun@huawei.com/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<dee5d56c6d6e30e4a77b7d62781e0995a727045d.1595648149.git.cloud.wangxiaoyun@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/dee5d56c6d6e30e4a77b7d62781e0995a727045d.1595648149.git.cloud.wangxiaoyun@huawei.com",
    "date": "2020-07-25T03:48:22",
    "name": "[v1,1/4] net/hinic: modify csum offload process",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ab6b1c33614c70e0662ffa559808cd81a6e1fc63",
    "submitter": {
        "id": 1446,
        "url": "http://patches.dpdk.org/api/people/1446/?format=api",
        "name": "Wangxiaoyun (Cloud)",
        "email": "cloud.wangxiaoyun@huawei.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/dee5d56c6d6e30e4a77b7d62781e0995a727045d.1595648149.git.cloud.wangxiaoyun@huawei.com/mbox/",
    "series": [
        {
            "id": 11298,
            "url": "http://patches.dpdk.org/api/series/11298/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=11298",
            "date": "2020-07-25T03:48:22",
            "name": "some bugs fixes",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/11298/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/74797/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/74797/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 37884A0527;\n\tSat, 25 Jul 2020 05:48:56 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id D44A41C02A;\n\tSat, 25 Jul 2020 05:48:54 +0200 (CEST)",
            "from huawei.com (szxga04-in.huawei.com [45.249.212.190])\n by dpdk.org (Postfix) with ESMTP id E91B31C029\n for <dev@dpdk.org>; Sat, 25 Jul 2020 05:48:51 +0200 (CEST)",
            "from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59])\n by Forcepoint Email with ESMTP id AD2921738C13015CE3C2;\n Sat, 25 Jul 2020 11:48:49 +0800 (CST)",
            "from tester.localdomain (10.175.119.39) by\n DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id\n 14.3.487.0; Sat, 25 Jul 2020 11:48:43 +0800"
        ],
        "From": "Xiaoyun wang <cloud.wangxiaoyun@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<ferruh.yigit@intel.com>, <bluca@debian.org>, <luoxianjun@huawei.com>,\n <luoxingyu@huawei.com>, <zhouguoyang@huawei.com>, <yin.yinshi@huawei.com>,\n <david.yangxiaoliang@huawei.com>, <zhaohui8@huawei.com>,\n <zhengjingzhou@huawei.com>, <guojian365@huawei.com>, Xiaoyun wang\n <cloud.wangxiaoyun@huawei.com>",
        "Date": "Sat, 25 Jul 2020 11:48:22 +0800",
        "Message-ID": "\n <dee5d56c6d6e30e4a77b7d62781e0995a727045d.1595648149.git.cloud.wangxiaoyun@huawei.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<cover.1595648149.git.cloud.wangxiaoyun@huawei.com>",
        "References": "<cover.1595648149.git.cloud.wangxiaoyun@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.175.119.39]",
        "X-CFilter-Loop": "Reflected",
        "Subject": "[dpdk-dev] [PATCH v1 1/4] net/hinic: modify csum offload process",
        "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": "Encapsulate different types of packet checksum preprocessing\ninto functions.\n\nSigned-off-by: Xiaoyun wang <cloud.wangxiaoyun@huawei.com>\n---\n drivers/net/hinic/hinic_pmd_tx.c | 371 +++++++++++++++++++++------------------\n 1 file changed, 202 insertions(+), 169 deletions(-)",
    "diff": "diff --git a/drivers/net/hinic/hinic_pmd_tx.c b/drivers/net/hinic/hinic_pmd_tx.c\nindex 4d99967..3ef15b2 100644\n--- a/drivers/net/hinic/hinic_pmd_tx.c\n+++ b/drivers/net/hinic/hinic_pmd_tx.c\n@@ -38,9 +38,6 @@\n #define HINIC_TSO_PKT_MAX_SGE\t\t\t127\t/* tso max sge 127 */\n #define HINIC_TSO_SEG_NUM_INVALID(num)\t\t((num) > HINIC_TSO_PKT_MAX_SGE)\n \n-#define HINIC_TX_OUTER_CHECKSUM_FLAG_SET       1\n-#define HINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET    0\n-\n /* sizeof(struct hinic_sq_bufdesc) == 16, shift 4 */\n #define HINIC_BUF_DESC_SIZE(nr_descs)\t(SIZE_8BYTES(((u32)nr_descs) << 4))\n \n@@ -671,7 +668,7 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)\n \n static inline struct hinic_sq_wqe *\n hinic_get_sq_wqe(struct hinic_txq *txq, int wqebb_cnt,\n-\t\tstruct hinic_wqe_info *wqe_info)\n+\t\t struct hinic_wqe_info *wqe_info)\n {\n \tu32 cur_pi, end_pi;\n \tu16 remain_wqebbs;\n@@ -758,36 +755,33 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)\n \treturn __rte_raw_cksum_reduce(sum);\n }\n \n-static inline void\n-hinic_get_pld_offset(struct rte_mbuf *m, struct hinic_tx_offload_info *off_info,\n-\t\t     int outer_cs_flag)\n+static inline void hinic_get_outer_cs_pld_offset(struct rte_mbuf *m,\n+\t\t\t\t\tstruct hinic_tx_offload_info *off_info)\n {\n \tuint64_t ol_flags = m->ol_flags;\n \n-\tif (outer_cs_flag == 1) {\n-\t\tif ((ol_flags & PKT_TX_UDP_CKSUM) == PKT_TX_UDP_CKSUM) {\n-\t\t\toff_info->payload_offset = m->outer_l2_len +\n-\t\t\t\tm->outer_l3_len + m->l2_len + m->l3_len;\n-\t\t} else if ((ol_flags & PKT_TX_TCP_CKSUM) ||\n-\t\t\t\t(ol_flags & PKT_TX_TCP_SEG)) {\n-\t\t\toff_info->payload_offset = m->outer_l2_len +\n-\t\t\t\t\tm->outer_l3_len + m->l2_len +\n-\t\t\t\t\tm->l3_len + m->l4_len;\n-\t\t}\n-\t} else {\n-\t\tif ((ol_flags & PKT_TX_UDP_CKSUM) == PKT_TX_UDP_CKSUM) {\n-\t\t\toff_info->payload_offset = m->l2_len + m->l3_len;\n-\t\t} else if ((ol_flags & PKT_TX_TCP_CKSUM) ||\n-\t\t\t(ol_flags & PKT_TX_TCP_SEG)) {\n-\t\t\toff_info->payload_offset = m->l2_len + m->l3_len +\n-\t\t\t\t\t\t   m->l4_len;\n-\t\t}\n-\t}\n+\tif ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM)\n+\t\toff_info->payload_offset = m->outer_l2_len + m->outer_l3_len +\n+\t\t\t\t\t   m->l2_len + m->l3_len;\n+\telse if ((ol_flags & PKT_TX_TCP_CKSUM) || (ol_flags & PKT_TX_TCP_SEG))\n+\t\toff_info->payload_offset = m->outer_l2_len + m->outer_l3_len +\n+\t\t\t\t\t   m->l2_len + m->l3_len + m->l4_len;\n }\n \n-static inline void\n-hinic_analyze_tx_info(struct rte_mbuf *mbuf,\n-\t\t      struct hinic_tx_offload_info *off_info)\n+static inline void hinic_get_pld_offset(struct rte_mbuf *m,\n+\t\t\t\t\tstruct hinic_tx_offload_info *off_info)\n+{\n+\tuint64_t ol_flags = m->ol_flags;\n+\n+\tif ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM)\n+\t\toff_info->payload_offset = m->l2_len + m->l3_len;\n+\telse if ((ol_flags & PKT_TX_TCP_CKSUM) || (ol_flags & PKT_TX_TCP_SEG))\n+\t\toff_info->payload_offset = m->l2_len + m->l3_len +\n+\t\t\t\t\t   m->l4_len;\n+}\n+\n+static inline void hinic_analyze_tx_info(struct rte_mbuf *mbuf,\n+\t\t\t\t\t struct hinic_tx_offload_info *off_info)\n {\n \tstruct rte_ether_hdr *eth_hdr;\n \tstruct rte_vlan_hdr *vlan_hdr;\n@@ -817,17 +811,164 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)\n \t}\n }\n \n-static inline int\n-hinic_tx_offload_pkt_prepare(struct rte_mbuf *m,\n-\t\t\t\tstruct hinic_tx_offload_info *off_info)\n+static inline void hinic_analyze_outer_ip_vxlan(struct rte_mbuf *mbuf,\n+\t\t\t\t\tstruct hinic_tx_offload_info *off_info)\n+{\n+\tstruct rte_ether_hdr *eth_hdr;\n+\tstruct rte_vlan_hdr *vlan_hdr;\n+\tstruct rte_ipv4_hdr *ipv4_hdr;\n+\tstruct rte_udp_hdr *udp_hdr;\n+\tu16 eth_type = 0;\n+\n+\teth_hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr *);\n+\teth_type = rte_be_to_cpu_16(eth_hdr->ether_type);\n+\n+\tif (eth_type == RTE_ETHER_TYPE_VLAN) {\n+\t\tvlan_hdr = (struct rte_vlan_hdr *)(eth_hdr + 1);\n+\t\teth_type = rte_be_to_cpu_16(vlan_hdr->eth_proto);\n+\t}\n+\n+\tif (eth_type == RTE_ETHER_TYPE_IPV4) {\n+\t\tipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,\n+\t\t\t\t\t\t   mbuf->outer_l2_len);\n+\t\toff_info->outer_l3_type = IPV4_PKT_WITH_CHKSUM_OFFLOAD;\n+\t\tipv4_hdr->hdr_checksum = 0;\n+\n+\t\tudp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr +\n+\t\t\t\t\t\t mbuf->outer_l3_len);\n+\t\tudp_hdr->dgram_cksum = 0;\n+\t} else if (eth_type == RTE_ETHER_TYPE_IPV6) {\n+\t\toff_info->outer_l3_type = IPV6_PKT;\n+\n+\t\tudp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_udp_hdr *,\n+\t\t\t\t\t\t  (mbuf->outer_l2_len +\n+\t\t\t\t\t\t   mbuf->outer_l3_len));\n+\t\tudp_hdr->dgram_cksum = 0;\n+\t}\n+}\n+\n+static inline uint8_t hinic_analyze_l3_type(struct rte_mbuf *mbuf)\n+{\n+\tuint8_t l3_type;\n+\tuint64_t ol_flags = mbuf->ol_flags;\n+\n+\tif (ol_flags & PKT_TX_IPV4)\n+\t\tl3_type = (ol_flags & PKT_TX_IP_CKSUM) ?\n+\t\t\t  IPV4_PKT_WITH_CHKSUM_OFFLOAD :\n+\t\t\t  IPV4_PKT_NO_CHKSUM_OFFLOAD;\n+\telse if (ol_flags & PKT_TX_IPV6)\n+\t\tl3_type = IPV6_PKT;\n+\telse\n+\t\tl3_type = UNKNOWN_L3TYPE;\n+\n+\treturn l3_type;\n+}\n+\n+static inline void hinic_calculate_tcp_checksum(struct rte_mbuf *mbuf,\n+\t\t\t\t\tstruct hinic_tx_offload_info *off_info,\n+\t\t\t\t\tuint64_t inner_l3_offset)\n {\n \tstruct rte_ipv4_hdr *ipv4_hdr;\n \tstruct rte_ipv6_hdr *ipv6_hdr;\n \tstruct rte_tcp_hdr *tcp_hdr;\n+\tuint64_t ol_flags = mbuf->ol_flags;\n+\n+\tif (ol_flags & PKT_TX_IPV4) {\n+\t\tipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,\n+\t\t\t\t\t\t   inner_l3_offset);\n+\n+\t\tif (ol_flags & PKT_TX_IP_CKSUM)\n+\t\t\tipv4_hdr->hdr_checksum = 0;\n+\n+\t\ttcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr +\n+\t\t\t\t\t\t mbuf->l3_len);\n+\t\ttcp_hdr->cksum = hinic_ipv4_phdr_cksum(ipv4_hdr, ol_flags);\n+\t} else {\n+\t\tipv6_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv6_hdr *,\n+\t\t\t\t\t\t   inner_l3_offset);\n+\t\ttcp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_tcp_hdr *,\n+\t\t\t\t\t\t  (inner_l3_offset +\n+\t\t\t\t\t\t   mbuf->l3_len));\n+\t\ttcp_hdr->cksum = hinic_ipv6_phdr_cksum(ipv6_hdr, ol_flags);\n+\t}\n+\n+\toff_info->inner_l4_type = TCP_OFFLOAD_ENABLE;\n+\toff_info->inner_l4_tcp_udp = 1;\n+}\n+\n+static inline void hinic_calculate_udp_checksum(struct rte_mbuf *mbuf,\n+\t\t\t\t\tstruct hinic_tx_offload_info *off_info,\n+\t\t\t\t\tuint64_t inner_l3_offset)\n+{\n+\tstruct rte_ipv4_hdr *ipv4_hdr;\n+\tstruct rte_ipv6_hdr *ipv6_hdr;\n \tstruct rte_udp_hdr *udp_hdr;\n-\tstruct rte_ether_hdr *eth_hdr;\n-\tstruct rte_vlan_hdr *vlan_hdr;\n-\tu16 eth_type = 0;\n+\tuint64_t ol_flags = mbuf->ol_flags;\n+\n+\tif (ol_flags & PKT_TX_IPV4) {\n+\t\tipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,\n+\t\t\t\t\t\t   inner_l3_offset);\n+\n+\t\tif (ol_flags & PKT_TX_IP_CKSUM)\n+\t\t\tipv4_hdr->hdr_checksum = 0;\n+\n+\t\tudp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr +\n+\t\t\t\t\t\t mbuf->l3_len);\n+\t\tudp_hdr->dgram_cksum = hinic_ipv4_phdr_cksum(ipv4_hdr,\n+\t\t\t\t\t\t\t     ol_flags);\n+\t} else {\n+\t\tipv6_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv6_hdr *,\n+\t\t\t\t\t\t   inner_l3_offset);\n+\n+\t\tudp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_udp_hdr *,\n+\t\t\t\t\t\t  (inner_l3_offset +\n+\t\t\t\t\t\t   mbuf->l3_len));\n+\t\tudp_hdr->dgram_cksum = hinic_ipv6_phdr_cksum(ipv6_hdr,\n+\t\t\t\t\t\t\t     ol_flags);\n+\t}\n+\n+\toff_info->inner_l4_type = UDP_OFFLOAD_ENABLE;\n+\toff_info->inner_l4_tcp_udp = 1;\n+}\n+\n+static inline void\n+hinic_calculate_sctp_checksum(struct hinic_tx_offload_info *off_info)\n+{\n+\toff_info->inner_l4_type = SCTP_OFFLOAD_ENABLE;\n+\toff_info->inner_l4_tcp_udp = 0;\n+\toff_info->inner_l4_len = sizeof(struct rte_sctp_hdr);\n+}\n+\n+static inline void hinic_calculate_checksum(struct rte_mbuf *mbuf,\n+\t\t\t\t\tstruct hinic_tx_offload_info *off_info,\n+\t\t\t\t\tuint64_t inner_l3_offset)\n+{\n+\tuint64_t ol_flags = mbuf->ol_flags;\n+\n+\tswitch (ol_flags & PKT_TX_L4_MASK) {\n+\tcase PKT_TX_UDP_CKSUM:\n+\t\thinic_calculate_udp_checksum(mbuf, off_info, inner_l3_offset);\n+\t\tbreak;\n+\n+\tcase PKT_TX_TCP_CKSUM:\n+\t\thinic_calculate_tcp_checksum(mbuf, off_info, inner_l3_offset);\n+\t\tbreak;\n+\n+\tcase PKT_TX_SCTP_CKSUM:\n+\t\thinic_calculate_sctp_checksum(off_info);\n+\t\tbreak;\n+\n+\tdefault:\n+\t\tif (ol_flags & PKT_TX_TCP_SEG)\n+\t\t\thinic_calculate_tcp_checksum(mbuf, off_info,\n+\t\t\t\t\t\t     inner_l3_offset);\n+\t\tbreak;\n+\t}\n+}\n+\n+static inline int hinic_tx_offload_pkt_prepare(struct rte_mbuf *m,\n+\t\t\t\t\tstruct hinic_tx_offload_info *off_info)\n+{\n \tuint64_t inner_l3_offset;\n \tuint64_t ol_flags = m->ol_flags;\n \n@@ -836,8 +977,8 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)\n \t\treturn 0;\n \n \t/* Support only vxlan offload */\n-\tif ((ol_flags & PKT_TX_TUNNEL_MASK) &&\n-\t    !(ol_flags & PKT_TX_TUNNEL_VXLAN))\n+\tif (unlikely((ol_flags & PKT_TX_TUNNEL_MASK) &&\n+\t    !(ol_flags & PKT_TX_TUNNEL_VXLAN)))\n \t\treturn -ENOTSUP;\n \n #ifdef RTE_LIBRTE_ETHDEV_DEBUG\n@@ -846,169 +987,61 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)\n #endif\n \n \tif (ol_flags & PKT_TX_TUNNEL_VXLAN) {\n+\t\toff_info->tunnel_type = TUNNEL_UDP_NO_CSUM;\n+\n+\t\t/* inner_l4_tcp_udp csum should be setted to calculate outter\n+\t\t * udp checksum when vxlan packets without inner l3 and l4\n+\t\t */\n+\t\toff_info->inner_l4_tcp_udp = 1;\n+\n \t\tif ((ol_flags & PKT_TX_OUTER_IP_CKSUM) ||\n \t\t    (ol_flags & PKT_TX_OUTER_IPV6) ||\n \t\t    (ol_flags & PKT_TX_TCP_SEG)) {\n \t\t\tinner_l3_offset = m->l2_len + m->outer_l2_len +\n-\t\t\t\tm->outer_l3_len;\n+\t\t\t\t\t  m->outer_l3_len;\n \t\t\toff_info->outer_l2_len = m->outer_l2_len;\n \t\t\toff_info->outer_l3_len = m->outer_l3_len;\n \t\t\t/* just support vxlan tunneling pkt */\n \t\t\toff_info->inner_l2_len = m->l2_len - VXLANLEN -\n-\t\t\t\tsizeof(*udp_hdr);\n-\t\t\toff_info->inner_l3_len = m->l3_len;\n-\t\t\toff_info->inner_l4_len = m->l4_len;\n+\t\t\t\t\t\t sizeof(struct rte_udp_hdr);\n \t\t\toff_info->tunnel_length = m->l2_len;\n-\t\t\toff_info->tunnel_type = TUNNEL_UDP_NO_CSUM;\n \n-\t\t\thinic_get_pld_offset(m, off_info,\n-\t\t\t\t\t     HINIC_TX_OUTER_CHECKSUM_FLAG_SET);\n+\t\t\thinic_analyze_outer_ip_vxlan(m, off_info);\n+\n+\t\t\thinic_get_outer_cs_pld_offset(m, off_info);\n \t\t} else {\n \t\t\tinner_l3_offset = m->l2_len;\n \t\t\thinic_analyze_tx_info(m, off_info);\n \t\t\t/* just support vxlan tunneling pkt */\n \t\t\toff_info->inner_l2_len = m->l2_len - VXLANLEN -\n-\t\t\t\tsizeof(*udp_hdr) - off_info->outer_l2_len -\n-\t\t\t\toff_info->outer_l3_len;\n-\t\t\toff_info->inner_l3_len = m->l3_len;\n-\t\t\toff_info->inner_l4_len = m->l4_len;\n+\t\t\t\t\t\t sizeof(struct rte_udp_hdr) -\n+\t\t\t\t\t\t off_info->outer_l2_len -\n+\t\t\t\t\t\t off_info->outer_l3_len;\n \t\t\toff_info->tunnel_length = m->l2_len -\n-\t\t\t\toff_info->outer_l2_len - off_info->outer_l3_len;\n-\t\t\toff_info->tunnel_type = TUNNEL_UDP_NO_CSUM;\n+\t\t\t\t\t\t  off_info->outer_l2_len -\n+\t\t\t\t\t\t  off_info->outer_l3_len;\n+\t\t\toff_info->outer_l3_type = IPV4_PKT_NO_CHKSUM_OFFLOAD;\n \n-\t\t\thinic_get_pld_offset(m, off_info,\n-\t\t\t\tHINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET);\n+\t\t\thinic_get_pld_offset(m, off_info);\n \t\t}\n \t} else {\n \t\tinner_l3_offset = m->l2_len;\n \t\toff_info->inner_l2_len = m->l2_len;\n-\t\toff_info->inner_l3_len = m->l3_len;\n-\t\toff_info->inner_l4_len = m->l4_len;\n \t\toff_info->tunnel_type = NOT_TUNNEL;\n \n-\t\thinic_get_pld_offset(m, off_info,\n-\t\t\t\t     HINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET);\n+\t\thinic_get_pld_offset(m, off_info);\n \t}\n \n \t/* invalid udp or tcp header */\n \tif (unlikely(off_info->payload_offset > MAX_PLD_OFFSET))\n \t\treturn -EINVAL;\n \n-\t/* Process outter udp pseudo-header checksum */\n-\tif ((ol_flags & PKT_TX_TUNNEL_VXLAN) && ((ol_flags & PKT_TX_TCP_SEG) ||\n-\t\t\t(ol_flags & PKT_TX_OUTER_IP_CKSUM) ||\n-\t\t\t(ol_flags & PKT_TX_OUTER_IPV6))) {\n-\n-\t\t/* inner_l4_tcp_udp csum should be setted to calculate outter\n-\t\t * udp checksum when vxlan packets without inner l3 and l4\n-\t\t */\n-\t\toff_info->inner_l4_tcp_udp = 1;\n-\n-\t\teth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);\n-\t\teth_type = rte_be_to_cpu_16(eth_hdr->ether_type);\n-\n-\t\tif (eth_type == RTE_ETHER_TYPE_VLAN) {\n-\t\t\tvlan_hdr = (struct rte_vlan_hdr *)(eth_hdr + 1);\n-\t\t\teth_type = rte_be_to_cpu_16(vlan_hdr->eth_proto);\n-\t\t}\n-\n-\t\tif (eth_type == RTE_ETHER_TYPE_IPV4) {\n-\t\t\tipv4_hdr =\n-\t\t\trte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,\n-\t\t\t\t\t\tm->outer_l2_len);\n-\t\t\toff_info->outer_l3_type = IPV4_PKT_WITH_CHKSUM_OFFLOAD;\n-\t\t\tipv4_hdr->hdr_checksum = 0;\n-\n-\t\t\tudp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr +\n-\t\t\t\t\t\t\tm->outer_l3_len);\n-\t\t\tudp_hdr->dgram_cksum = 0;\n-\t\t} else if (eth_type == RTE_ETHER_TYPE_IPV6) {\n-\t\t\toff_info->outer_l3_type = IPV6_PKT;\n-\t\t\tipv6_hdr =\n-\t\t\trte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *,\n-\t\t\t\t\t\tm->outer_l2_len);\n-\n-\t\t\tudp_hdr =\n-\t\t\trte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *,\n-\t\t\t\t\t\t(m->outer_l2_len +\n-\t\t\t\t\t\tm->outer_l3_len));\n-\t\t\tudp_hdr->dgram_cksum = 0;\n-\t\t}\n-\t} else if (ol_flags & PKT_TX_OUTER_IPV4) {\n-\t\toff_info->tunnel_type = TUNNEL_UDP_NO_CSUM;\n-\t\toff_info->inner_l4_tcp_udp = 1;\n-\t\toff_info->outer_l3_type = IPV4_PKT_NO_CHKSUM_OFFLOAD;\n-\t}\n-\n-\tif (ol_flags & PKT_TX_IPV4)\n-\t\toff_info->inner_l3_type = (ol_flags & PKT_TX_IP_CKSUM) ?\n-\t\t\t\t\tIPV4_PKT_WITH_CHKSUM_OFFLOAD :\n-\t\t\t\t\tIPV4_PKT_NO_CHKSUM_OFFLOAD;\n-\telse if (ol_flags & PKT_TX_IPV6)\n-\t\toff_info->inner_l3_type = IPV6_PKT;\n+\toff_info->inner_l3_len = m->l3_len;\n+\toff_info->inner_l4_len = m->l4_len;\n+\toff_info->inner_l3_type = hinic_analyze_l3_type(m);\n \n \t/* Process the pseudo-header checksum */\n-\tif ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM) {\n-\t\tif (ol_flags & PKT_TX_IPV4) {\n-\t\t\tipv4_hdr =\n-\t\t\trte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,\n-\t\t\t\t\t\tinner_l3_offset);\n-\n-\t\t\tif (ol_flags & PKT_TX_IP_CKSUM)\n-\t\t\t\tipv4_hdr->hdr_checksum = 0;\n-\n-\t\t\tudp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr +\n-\t\t\t\t\t\t\t\tm->l3_len);\n-\t\t\tudp_hdr->dgram_cksum =\n-\t\t\t\thinic_ipv4_phdr_cksum(ipv4_hdr, ol_flags);\n-\t\t} else {\n-\t\t\tipv6_hdr =\n-\t\t\trte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *,\n-\t\t\t\t\t\tinner_l3_offset);\n-\n-\t\t\tudp_hdr =\n-\t\t\trte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *,\n-\t\t\t\t\t\t(inner_l3_offset + m->l3_len));\n-\t\t\tudp_hdr->dgram_cksum =\n-\t\t\t\thinic_ipv6_phdr_cksum(ipv6_hdr, ol_flags);\n-\t\t}\n-\n-\t\toff_info->inner_l4_type = UDP_OFFLOAD_ENABLE;\n-\t\toff_info->inner_l4_tcp_udp = 1;\n-\t} else if (((ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) ||\n-\t\t\t(ol_flags & PKT_TX_TCP_SEG)) {\n-\t\tif (ol_flags & PKT_TX_IPV4) {\n-\t\t\tipv4_hdr =\n-\t\t\trte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,\n-\t\t\t\t\t\tinner_l3_offset);\n-\n-\t\t\tif (ol_flags & PKT_TX_IP_CKSUM)\n-\t\t\t\tipv4_hdr->hdr_checksum = 0;\n-\n-\t\t\t/* non-TSO tcp */\n-\t\t\ttcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr +\n-\t\t\t\t\t\t\t\tm->l3_len);\n-\t\t\ttcp_hdr->cksum =\n-\t\t\t\thinic_ipv4_phdr_cksum(ipv4_hdr, ol_flags);\n-\t\t} else {\n-\t\t\tipv6_hdr =\n-\t\t\trte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *,\n-\t\t\t\t\t\tinner_l3_offset);\n-\t\t\t/* non-TSO tcp */\n-\t\t\ttcp_hdr =\n-\t\t\trte_pktmbuf_mtod_offset(m, struct rte_tcp_hdr *,\n-\t\t\t\t\t\t(inner_l3_offset + m->l3_len));\n-\t\t\ttcp_hdr->cksum =\n-\t\t\t\thinic_ipv6_phdr_cksum(ipv6_hdr, ol_flags);\n-\t\t}\n-\n-\t\toff_info->inner_l4_type = TCP_OFFLOAD_ENABLE;\n-\t\toff_info->inner_l4_tcp_udp = 1;\n-\t} else if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_SCTP_CKSUM) {\n-\t\toff_info->inner_l4_type = SCTP_OFFLOAD_ENABLE;\n-\t\toff_info->inner_l4_tcp_udp = 0;\n-\t\toff_info->inner_l4_len = sizeof(struct rte_sctp_hdr);\n-\t}\n+\thinic_calculate_checksum(m, off_info, inner_l3_offset);\n \n \treturn 0;\n }\n",
    "prefixes": [
        "v1",
        "1/4"
    ]
}