From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20045.outbound.protection.outlook.com [40.107.2.45]) by dpdk.org (Postfix) with ESMTP id 90018A48B for ; Wed, 17 Jan 2018 07:56:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=h3sqmY/53jux3cXXHyooWa0E/ukdKxhqwMlFzP6Tp/M=; b=tgWO+Y3K+MoHuApfMv9DhwFxTxPKtWq9JkNmLk7KhNBxkT0iqf2RbZrFt5wxxSjiaJnf35U0uFRXp3ETgtivlT/59y2tly9S7n1FwbNg6cCFWbI/PDv8mCXPHDsXRClI9+JZhBCQM5f5uGNLELve/i4DXgUU0co+SvUNv3jgIZ0= Received: from VI1PR05MB3149.eurprd05.prod.outlook.com (10.170.237.142) by VI1PR05MB1103.eurprd05.prod.outlook.com (10.162.11.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Wed, 17 Jan 2018 06:56:26 +0000 Received: from VI1PR05MB3149.eurprd05.prod.outlook.com ([fe80::789c:3f06:bb88:e29c]) by VI1PR05MB3149.eurprd05.prod.outlook.com ([fe80::789c:3f06:bb88:e29c%13]) with mapi id 15.20.0407.012; Wed, 17 Jan 2018 06:56:26 +0000 From: Shahaf Shuler To: Rafal Kozik , "dev@dpdk.org" CC: "mw@semihalf.com" , "mk@semihalf.com" , "gtzalik@amazon.com" , "evgenys@amazon.com" , "matua@amazon.com" , "igorch@amazon.com" Thread-Topic: [dpdk-dev] [PATCH 1/2] net/ena: convert to new Tx offloads API Thread-Index: AQHTjsCbYsQ95eBPK0y2FObnsEl7RqN3ogMw Date: Wed, 17 Jan 2018 06:56:26 +0000 Message-ID: References: <1516103563-9275-1-git-send-email-rk@semihalf.com> <1516103563-9275-2-git-send-email-rk@semihalf.com> In-Reply-To: <1516103563-9275-2-git-send-email-rk@semihalf.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR05MB1103; 7:fZUGZa/m7hwh8ggPvzi+SS4sw7BTLAJyWMfvF6DZjqoK/d/5xfqjNXrw6wb8//SsY4I+rCSmb6Vj/a71S0ZQ+AK313E4Yp9Ri76IkgBoXxeom1/pftpeMmRE741y4ewDvXv813aLd94/VU4ER5EH4T6a2fTNWHCDWk2vukFo/0ey5+cJXO42XRfR4kcujWYaRsTAthxeY7pQrEvYx6aVAeh8tt5gaUYy1kpPBMmy4URevm6tk3h+U8xt1f768for x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 5e2de5f8-183a-4c3f-b20b-08d55d776da0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(48565401081)(2017052603307)(7153060)(7193020); SRVR:VI1PR05MB1103; x-ms-traffictypediagnostic: VI1PR05MB1103: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(278428928389397); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231023)(944501161)(10201501046)(6055026)(6041268)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:VI1PR05MB1103; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:VI1PR05MB1103; x-forefront-prvs: 0555EC8317 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39380400002)(346002)(39860400002)(396003)(376002)(366004)(199004)(189003)(4326008)(2950100002)(2906002)(105586002)(76176011)(66066001)(106356001)(25786009)(14454004)(33656002)(6246003)(102836004)(5250100002)(478600001)(6506007)(2501003)(7696005)(5660300001)(2900100001)(81156014)(81166006)(3846002)(8676002)(6116002)(54906003)(110136005)(229853002)(3660700001)(9686003)(55016002)(3280700002)(99286004)(8936002)(7736002)(26005)(305945005)(74316002)(86362001)(6436002)(575784001)(53936002)(97736004)(316002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB1103; H:VI1PR05MB3149.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: zqEyXUSffHRNNMTAiv/RzFZqhcYjO2Xpa2grnLp5OaxpW93/PdUXRJ6HvcswC9rSieK062h4GyZU0wEiGRv2Iw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e2de5f8-183a-4c3f-b20b-08d55d776da0 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2018 06:56:26.3751 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1103 Subject: Re: [dpdk-dev] [PATCH 1/2] net/ena: convert to new Tx offloads API 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: , X-List-Received-Date: Wed, 17 Jan 2018 06:56:29 -0000 Tuesday, January 16, 2018 1:53 PM, Rafal Kozik: > Subject: [dpdk-dev] [PATCH 1/2] net/ena: convert to new Tx offloads API >=20 > Ethdev Tx offloads API has changed since: >=20 > commit cba7f53b717d ("ethdev: introduce Tx queue offloads API") >=20 > This commit support the new Tx offloads API. Queue configuration is store= d > in ena_ring.offloads. During preparing mbufs for tx, offloads are allowed= only > if appropriate flags in this field are set. >=20 > Signed-off-by: Rafal Kozik > --- > drivers/net/ena/ena_ethdev.c | 73 > +++++++++++++++++++++++++++++++++++--------- > drivers/net/ena/ena_ethdev.h | 3 ++ > 2 files changed, 61 insertions(+), 15 deletions(-) >=20 > diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c > index 22db895..6473776 100644 > --- a/drivers/net/ena/ena_ethdev.c > +++ b/drivers/net/ena/ena_ethdev.c > @@ -164,6 +164,14 @@ static const struct ena_stats > ena_stats_ena_com_strings[] =3D { > #define ENA_STATS_ARRAY_RX ARRAY_SIZE(ena_stats_rx_strings) > #define ENA_STATS_ARRAY_ENA_COM > ARRAY_SIZE(ena_stats_ena_com_strings) >=20 > +#define QUEUE_OFFLOADS (DEV_TX_OFFLOAD_TCP_CKSUM |\ > + DEV_TX_OFFLOAD_UDP_CKSUM |\ > + DEV_TX_OFFLOAD_IPV4_CKSUM |\ > + DEV_TX_OFFLOAD_TCP_TSO) > +#define MBUF_OFFLOADS (PKT_TX_L4_MASK |\ > + PKT_TX_IP_CKSUM |\ > + PKT_TX_TCP_SEG) > + > /** Vendor ID used by Amazon devices */ #define > PCI_VENDOR_ID_AMAZON 0x1D0F > /** Amazon devices */ > @@ -227,6 +235,8 @@ static int ena_rss_reta_query(struct rte_eth_dev > *dev, > struct rte_eth_rss_reta_entry64 *reta_conf, > uint16_t reta_size); > static int ena_get_sset_count(struct rte_eth_dev *dev, int sset); > +static bool ena_are_tx_queue_offloads_allowed(struct ena_adapter > *adapter, > + uint64_t offloads); >=20 > static const struct eth_dev_ops ena_dev_ops =3D { > .dev_configure =3D ena_dev_configure, > @@ -280,21 +290,24 @@ static inline void ena_rx_mbuf_prepare(struct > rte_mbuf *mbuf, } >=20 > static inline void ena_tx_mbuf_prepare(struct rte_mbuf *mbuf, > - struct ena_com_tx_ctx *ena_tx_ctx) > + struct ena_com_tx_ctx *ena_tx_ctx, > + uint64_t queue_offloads) > { > struct ena_com_tx_meta *ena_meta =3D &ena_tx_ctx->ena_meta; >=20 > - if (mbuf->ol_flags & > - (PKT_TX_L4_MASK | PKT_TX_IP_CKSUM | PKT_TX_TCP_SEG)) { > + if ((mbuf->ol_flags & MBUF_OFFLOADS) && > + (queue_offloads & QUEUE_OFFLOADS)) { > /* check if TSO is required */ > - if (mbuf->ol_flags & PKT_TX_TCP_SEG) { > + if ((mbuf->ol_flags & PKT_TX_TCP_SEG) && > + (queue_offloads & DEV_TX_OFFLOAD_TCP_TSO)) { > ena_tx_ctx->tso_enable =3D true; >=20 > ena_meta->l4_hdr_len =3D GET_L4_HDR_LEN(mbuf); > } >=20 > /* check if L3 checksum is needed */ > - if (mbuf->ol_flags & PKT_TX_IP_CKSUM) > + if ((mbuf->ol_flags & PKT_TX_IP_CKSUM) && > + (queue_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM)) > ena_tx_ctx->l3_csum_enable =3D true; >=20 > if (mbuf->ol_flags & PKT_TX_IPV6) { > @@ -310,19 +323,17 @@ static inline void ena_tx_mbuf_prepare(struct > rte_mbuf *mbuf, > } >=20 > /* check if L4 checksum is needed */ > - switch (mbuf->ol_flags & PKT_TX_L4_MASK) { > - case PKT_TX_TCP_CKSUM: > + if ((mbuf->ol_flags & PKT_TX_TCP_CKSUM) && > + (queue_offloads & DEV_TX_OFFLOAD_TCP_CKSUM)) { > ena_tx_ctx->l4_proto =3D > ENA_ETH_IO_L4_PROTO_TCP; > ena_tx_ctx->l4_csum_enable =3D true; > - break; > - case PKT_TX_UDP_CKSUM: > + } else if ((mbuf->ol_flags & PKT_TX_UDP_CKSUM) && > + (queue_offloads & > DEV_TX_OFFLOAD_UDP_CKSUM)) { > ena_tx_ctx->l4_proto =3D > ENA_ETH_IO_L4_PROTO_UDP; > ena_tx_ctx->l4_csum_enable =3D true; > - break; > - default: > + } else { > ena_tx_ctx->l4_proto =3D > ENA_ETH_IO_L4_PROTO_UNKNOWN; > ena_tx_ctx->l4_csum_enable =3D false; > - break; > } >=20 > ena_meta->mss =3D mbuf->tso_segsz; > @@ -945,7 +956,7 @@ static int ena_tx_queue_setup(struct rte_eth_dev > *dev, > uint16_t queue_idx, > uint16_t nb_desc, > __rte_unused unsigned int socket_id, > - __rte_unused const struct rte_eth_txconf > *tx_conf) > + const struct rte_eth_txconf *tx_conf) > { > struct ena_com_create_io_ctx ctx =3D > /* policy set to _HOST just to satisfy icc compiler */ @@ - > 982,6 +993,11 @@ static int ena_tx_queue_setup(struct rte_eth_dev *dev, > return -EINVAL; > } >=20 > + if (!ena_are_tx_queue_offloads_allowed(adapter, tx_conf- > >offloads)) { > + RTE_LOG(ERR, PMD, "Unsupported queue offloads\n"); > + return -EINVAL; > + } Here is it better to check also the ETH_TXQ_FLAGS_IGNORE. If application has not yet moved to the new API, then it won't set any port= Tx offloads. So for old applications, the ena_are_tx_queue_offloads_allowe= d is not necessary.=20 > + > ena_qid =3D ENA_IO_TXQ_IDX(queue_idx); >=20 > ctx.direction =3D ENA_COM_IO_QUEUE_DIRECTION_TX; @@ -1036,6 > +1052,8 @@ static int ena_tx_queue_setup(struct rte_eth_dev *dev, > for (i =3D 0; i < txq->ring_size; i++) > txq->empty_tx_reqs[i] =3D i; >=20 > + txq->offloads =3D tx_conf->offloads; > + > /* Store pointer to this queue in upper layer */ > txq->configured =3D 1; > dev->data->tx_queues[queue_idx] =3D txq; @@ -1386,6 +1404,14 @@ > static int ena_dev_configure(struct rte_eth_dev *dev) { > struct ena_adapter *adapter =3D > (struct ena_adapter *)(dev->data->dev_private); > + uint64_t tx_offloads =3D dev->data->dev_conf.txmode.offloads; > + > + if ((tx_offloads & adapter->tx_supported_offloads) !=3D tx_offloads) { > + RTE_LOG(ERR, PMD, "Some Tx offloads are not supported " > + "requested 0x%lx supported 0x%lx\n", > + tx_offloads, adapter->tx_supported_offloads); > + return -ENOTSUP; > + } 32bit compilation will break with above print. Using PRIx64 is preferable (= I also changed it on the mlx series). >=20 > if (!(adapter->state =3D=3D ENA_ADAPTER_STATE_INIT || > adapter->state =3D=3D ENA_ADAPTER_STATE_STOPPED)) { @@ - > 1407,6 +1433,7 @@ static int ena_dev_configure(struct rte_eth_dev *dev) > break; > } >=20 > + adapter->tx_selected_offloads =3D tx_offloads; > return 0; > } >=20 > @@ -1435,13 +1462,26 @@ static void ena_init_rings(struct ena_adapter > *adapter) > } > } >=20 > +static bool ena_are_tx_queue_offloads_allowed(struct ena_adapter > *adapter, > + uint64_t offloads) > +{ > + uint64_t port_offloads =3D adapter->tx_selected_offloads; > + > + /* Check if port supports all requested offloads. > + * True if all offloads selected for queue are set for port. > + */ > + if ((offloads & port_offloads) !=3D offloads) > + return false; > + return true; > +} > + > static void ena_infos_get(struct rte_eth_dev *dev, > struct rte_eth_dev_info *dev_info) { > struct ena_adapter *adapter; > struct ena_com_dev *ena_dev; > struct ena_com_dev_get_features_ctx feat; > - uint32_t rx_feat =3D 0, tx_feat =3D 0; > + uint64_t rx_feat =3D 0, tx_feat =3D 0; > int rc =3D 0; >=20 > ena_assert_msg(dev->data !=3D NULL, "Uninitialized device"); @@ - > 1490,6 +1530,7 @@ static void ena_infos_get(struct rte_eth_dev *dev, > /* Inform framework about available features */ > dev_info->rx_offload_capa =3D rx_feat; > dev_info->tx_offload_capa =3D tx_feat; > + dev_info->tx_queue_offload_capa =3D tx_feat; >=20 > dev_info->min_rx_bufsize =3D ENA_MIN_FRAME_LEN; > dev_info->max_rx_pktlen =3D adapter->max_mtu; @@ -1498,6 > +1539,8 @@ static void ena_infos_get(struct rte_eth_dev *dev, > dev_info->max_rx_queues =3D adapter->num_queues; > dev_info->max_tx_queues =3D adapter->num_queues; > dev_info->reta_size =3D ENA_RX_RSS_TABLE_SIZE; > + > + adapter->tx_supported_offloads =3D tx_feat; > } >=20 > static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf > **rx_pkts, @@ -1714,7 +1757,7 @@ static uint16_t eth_ena_xmit_pkts(void > *tx_queue, struct rte_mbuf **tx_pkts, > } /* there's no else as we take advantage of memset zeroing > */ >=20 > /* Set TX offloads flags, if applicable */ > - ena_tx_mbuf_prepare(mbuf, &ena_tx_ctx); > + ena_tx_mbuf_prepare(mbuf, &ena_tx_ctx, tx_ring- > >offloads); >=20 > if (unlikely(mbuf->ol_flags & > (PKT_RX_L4_CKSUM_BAD | > PKT_RX_IP_CKSUM_BAD))) diff --git a/drivers/net/ena/ena_ethdev.h > b/drivers/net/ena/ena_ethdev.h index be8bc9f..3e72777 100644 > --- a/drivers/net/ena/ena_ethdev.h > +++ b/drivers/net/ena/ena_ethdev.h > @@ -91,6 +91,7 @@ struct ena_ring { > uint8_t tx_max_header_size; > int configured; > struct ena_adapter *adapter; > + uint64_t offloads; > } __rte_cache_aligned; >=20 > enum ena_adapter_state { > @@ -175,6 +176,8 @@ struct ena_adapter { > struct ena_driver_stats *drv_stats; > enum ena_adapter_state state; >=20 > + uint64_t tx_supported_offloads; > + uint64_t tx_selected_offloads; > }; >=20 > #endif /* _ENA_ETHDEV_H_ */ Rest looks OK.=20 Reviewed-By: Shahaf Shuler > -- > 2.7.4