From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id C6052A0096 for ; Mon, 8 Apr 2019 13:24:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6396C5F28; Mon, 8 Apr 2019 13:23:14 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50042.outbound.protection.outlook.com [40.107.5.42]) by dpdk.org (Postfix) with ESMTP id F3C7A54AE for ; Mon, 8 Apr 2019 13:22:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DbjMsF5vt806iWkC+JxpMc55YR7NvTCv0aLWl+n0SjA=; b=IXA53KwJBfpTfyysx1Fl/35qb99hLvWx+U0Txp8egT6vii5AMgB7n8iS/IS5yq2yrnOEQedwNGwFxCceFX57lRGVANhl1XBPWY3L50zPg0iX5eUD+QpOFriZGGb1XZeUO5Yv4eS1SFescS2v2DxnjbEHFmDBcLqCswed3e1NyL8= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6670.eurprd04.prod.outlook.com (20.179.235.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.16; Mon, 8 Apr 2019 11:22:47 +0000 Received: from VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0]) by VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0%3]) with mapi id 15.20.1771.016; Mon, 8 Apr 2019 11:22:47 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH 12/13] net/enetc: enable Rx checksum offload validation Thread-Index: AQHU7f1kgRWad6/JCUiSiq5m3cB1xQ== Date: Mon, 8 Apr 2019 11:22:47 +0000 Message-ID: <1554745507-15089-13-git-send-email-g.singh@nxp.com> References: <1554745507-15089-1-git-send-email-g.singh@nxp.com> In-Reply-To: <1554745507-15089-1-git-send-email-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::13) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 1.9.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.1.67] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ee12bda3-6d66-47ea-653d-08d6bc14871c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR04MB6670; x-ms-traffictypediagnostic: VE1PR04MB6670: x-microsoft-antispam-prvs: x-forefront-prvs: 0001227049 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(136003)(376002)(39860400002)(396003)(199004)(189003)(86362001)(3846002)(6116002)(102836004)(8676002)(2616005)(186003)(68736007)(105586002)(81166006)(81156014)(72206003)(97736004)(5660300002)(6436002)(305945005)(6486002)(14454004)(6512007)(66066001)(7736002)(106356001)(26005)(50226002)(316002)(110136005)(476003)(486006)(25786009)(2501003)(11346002)(71190400001)(256004)(52116002)(53936002)(446003)(2906002)(6506007)(99286004)(478600001)(386003)(71200400001)(8936002)(76176011)(14444005)(4326008)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6670; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: coH+Sb1DnMMcL5h1qPKaGsnIE8ZipZ61JQ+HpOOfe129pxJSj9oSotIvZnY/941G/VMuk2F4/917soNK5/fn0KS85Tt+udqk6NNpNfqCMlT5121I4Ch4hiAhySYQe0ODZbStd0srVuBHiWyTejv7N/rzpyM5atFyBfkNIxseqqsJfmc3zQRNHAlNhokwxxHTv3VGh1tNXXkNC97GrnZ3jIPdOvTIm+ovxAeURF2SaO1TeMJhQupHFgnKr1UxlwahaGcJpJHFqQiflmDrBHOTdHdm+3hrqY7Ea/FEuR+s4OMNPizsUlJ3ImBYFDk4Z2KKzivsT5/G4A1jh0xP1laZvSq7+ST89rEQwxw5Xb9xmeXIoo3kTWwdo/xAx3Yr6tnkTr7zyGjK8M+ZV4+8ZMszLld6/ZOEzSnceFPP1VzCZy8= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee12bda3-6d66-47ea-653d-08d6bc14871c X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2019 11:22:47.5739 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6670 Subject: [dpdk-dev] [PATCH 12/13] net/enetc: enable Rx checksum offload validation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190408112247.niY22w1DZbqaoeYI8RFxih0C5vNFjCeMWl_ApGXlTng@z> Checksum Validation on Rx is supported. Signed-off-by: Gagandeep Singh --- doc/guides/nics/features/enetc.ini | 2 + drivers/net/enetc/base/enetc_hw.h | 5 ++ drivers/net/enetc/enetc_ethdev.c | 15 +++++- drivers/net/enetc/enetc_rxtx.c | 107 ++++++++++++++++++++++++++++++++-= ---- 4 files changed, 115 insertions(+), 14 deletions(-) diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/= enetc.ini index 101dc0a..39a5201 100644 --- a/doc/guides/nics/features/enetc.ini +++ b/doc/guides/nics/features/enetc.ini @@ -13,6 +13,8 @@ MTU update =3D Y Jumbo frame =3D Y Queue start/stop =3D Y CRC offload =3D Y +L3 checksum offload =3D P +L4 checksum offload =3D P Linux VFIO =3D Y ARMv8 =3D Y Usage doc =3D Y diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/ene= tc_hw.h index 261ad15..ff2bda5 100644 --- a/drivers/net/enetc/base/enetc_hw.h +++ b/drivers/net/enetc/base/enetc_hw.h @@ -99,6 +99,10 @@ #define ENETC_PM0_RX_EN BIT(1) #define ENETC_PM0_CRC BIT(6) =20 +#define ENETC_PAR_PORT_CFG 0x03050 +#define L3_CKSUM BIT(0) +#define L4_CKSUM BIT(1) + #define ENETC_PM0_MAXFRM 0x08014 #define ENETC_SET_TX_MTU(val) ((val) << 16) #define ENETC_SET_MAXFRM(val) ((val) & 0xffff) @@ -182,6 +186,7 @@ #define ENETC_TXBD_FLAGS_F BIT(15) =20 /* ENETC Parsed values (Little Endian) */ +#define ENETC_PARSE_ERROR 0x8000 #define ENETC_PKT_TYPE_ETHER 0x0060 #define ENETC_PKT_TYPE_IPV4 0x0000 #define ENETC_PKT_TYPE_IPV6 0x0020 diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_eth= dev.c index a59a030..6b49fd4 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -163,7 +163,10 @@ dev_info->max_tx_queues =3D MAX_TX_RINGS; dev_info->max_rx_pktlen =3D ENETC_MAC_MAXFRM_SIZE; dev_info->rx_offload_capa =3D - (DEV_RX_OFFLOAD_KEEP_CRC | + (DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM | + DEV_RX_OFFLOAD_KEEP_CRC | DEV_RX_OFFLOAD_JUMBO_FRAME); } =20 @@ -641,6 +644,7 @@ int enetc_stats_get(struct rte_eth_dev *dev, struct enetc_hw *enetc_hw =3D &hw->hw; struct rte_eth_conf *eth_conf =3D &dev->data->dev_conf; uint64_t rx_offloads =3D eth_conf->rxmode.offloads; + uint32_t checksum =3D L3_CKSUM | L4_CKSUM; =20 PMD_INIT_FUNC_TRACE(); =20 @@ -666,6 +670,15 @@ int enetc_stats_get(struct rte_eth_dev *dev, enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, config); } =20 + if (rx_offloads & DEV_RX_OFFLOAD_IPV4_CKSUM) + checksum &=3D ~L3_CKSUM; + + if (rx_offloads & (DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM)) + checksum &=3D ~L4_CKSUM; + + enetc_port_wr(enetc_hw, ENETC_PAR_PORT_CFG, checksum); + + return 0; } =20 diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.= c index 7497a47..ed39665 100644 --- a/drivers/net/enetc/enetc_rxtx.c +++ b/drivers/net/enetc/enetc_rxtx.c @@ -114,69 +114,150 @@ return j; } =20 +static inline void enetc_slow_parsing(struct rte_mbuf *m, + uint64_t parse_results) +{ + m->ol_flags &=3D ~(PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD); + + switch (parse_results) { + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV4; + m->ol_flags |=3D PKT_RX_IP_CKSUM_BAD; + return; + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV6; + m->ol_flags |=3D PKT_RX_IP_CKSUM_BAD; + return; + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_TCP: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV4 | + RTE_PTYPE_L4_TCP; + m->ol_flags |=3D PKT_RX_IP_CKSUM_GOOD | + PKT_RX_L4_CKSUM_BAD; + return; + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_TCP: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV6 | + RTE_PTYPE_L4_TCP; + m->ol_flags |=3D PKT_RX_IP_CKSUM_GOOD | + PKT_RX_L4_CKSUM_BAD; + return; + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_UDP: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV4 | + RTE_PTYPE_L4_UDP; + m->ol_flags |=3D PKT_RX_IP_CKSUM_GOOD | + PKT_RX_L4_CKSUM_BAD; + return; + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_UDP: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV6 | + RTE_PTYPE_L4_UDP; + m->ol_flags |=3D PKT_RX_IP_CKSUM_GOOD | + PKT_RX_L4_CKSUM_BAD; + return; + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_SCTP: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV4 | + RTE_PTYPE_L4_SCTP; + m->ol_flags |=3D PKT_RX_IP_CKSUM_GOOD | + PKT_RX_L4_CKSUM_BAD; + return; + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_SCTP: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV6 | + RTE_PTYPE_L4_SCTP; + m->ol_flags |=3D PKT_RX_IP_CKSUM_GOOD | + PKT_RX_L4_CKSUM_BAD; + return; + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV4_ICMP: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV4 | + RTE_PTYPE_L4_ICMP; + m->ol_flags |=3D PKT_RX_IP_CKSUM_GOOD | + PKT_RX_L4_CKSUM_BAD; + return; + case ENETC_PARSE_ERROR | ENETC_PKT_TYPE_IPV6_ICMP: + m->packet_type =3D RTE_PTYPE_L2_ETHER | + RTE_PTYPE_L3_IPV6 | + RTE_PTYPE_L4_ICMP; + m->ol_flags |=3D PKT_RX_IP_CKSUM_GOOD | + PKT_RX_L4_CKSUM_BAD; + return; + /* More switch cases can be added */ + default: + m->packet_type =3D RTE_PTYPE_UNKNOWN; + m->ol_flags |=3D PKT_RX_IP_CKSUM_UNKNOWN | + PKT_RX_L4_CKSUM_UNKNOWN; + } +} + =20 static inline void __attribute__((hot)) enetc_dev_rx_parse(struct rte_mbuf *m, uint16_t parse_results) { ENETC_PMD_DP_DEBUG("parse summary =3D 0x%x ", parse_results); + m->ol_flags |=3D PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD; =20 - m->packet_type =3D RTE_PTYPE_UNKNOWN; switch (parse_results) { case ENETC_PKT_TYPE_ETHER: m->packet_type =3D RTE_PTYPE_L2_ETHER; - break; + return; case ENETC_PKT_TYPE_IPV4: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4; - break; + return; case ENETC_PKT_TYPE_IPV6: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6; - break; + return; case ENETC_PKT_TYPE_IPV4_TCP: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP; - break; + return; case ENETC_PKT_TYPE_IPV6_TCP: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP; - break; + return; case ENETC_PKT_TYPE_IPV4_UDP: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP; - break; + return; case ENETC_PKT_TYPE_IPV6_UDP: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP; - break; + return; case ENETC_PKT_TYPE_IPV4_SCTP: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_SCTP; - break; + return; case ENETC_PKT_TYPE_IPV6_SCTP: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_SCTP; - break; + return; case ENETC_PKT_TYPE_IPV4_ICMP: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_ICMP; - break; + return; case ENETC_PKT_TYPE_IPV6_ICMP: m->packet_type =3D RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_ICMP; - break; + return; /* More switch cases can be added */ default: - m->packet_type =3D RTE_PTYPE_UNKNOWN; + enetc_slow_parsing(m, parse_results); } + } =20 static int --=20 1.9.1