From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 2A1CC11C5 for ; Fri, 15 Jan 2016 16:03:32 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 15 Jan 2016 07:03:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,300,1449561600"; d="scan'208";a="727720540" Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by orsmga003.jf.intel.com with ESMTP; 15 Jan 2016 07:03:15 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.104]) by IRSMSX108.ger.corp.intel.com ([169.254.11.160]) with mapi id 14.03.0248.002; Fri, 15 Jan 2016 15:03:13 +0000 From: "Ananyev, Konstantin" To: "Tan, Jianfeng" , "dev@dpdk.org" Thread-Topic: [PATCH v2 01/12] ethdev: add API to query packet type filling info Thread-Index: AQHRT5LBzIQ8xSOrQkuYMeiXqH5ZgJ78q0KA Date: Fri, 15 Jan 2016 15:03:12 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725836AE6184@irsmsx105.ger.corp.intel.com> References: <1451544799-70776-1-git-send-email-jianfeng.tan@intel.com> <1452836759-63540-1-git-send-email-jianfeng.tan@intel.com> <1452836759-63540-2-git-send-email-jianfeng.tan@intel.com> In-Reply-To: <1452836759-63540-2-git-send-email-jianfeng.tan@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 01/12] ethdev: add API to query packet type filling info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2016 15:03:32 -0000 > -----Original Message----- > From: Tan, Jianfeng > Sent: Friday, January 15, 2016 5:46 AM > To: dev@dpdk.org > Cc: Zhang, Helin; Ananyev, Konstantin; Tan, Jianfeng > Subject: [PATCH v2 01/12] ethdev: add API to query packet type filling in= fo >=20 > Add a new API rte_eth_dev_get_ptype_info to query wether/what packet type= will > be filled by given pmd rx burst function. >=20 > Signed-off-by: Jianfeng Tan > --- > lib/librte_ether/rte_ethdev.c | 20 ++++++++++++++++++++ > lib/librte_ether/rte_ethdev.h | 27 +++++++++++++++++++++++++++ > lib/librte_mbuf/rte_mbuf.h | 6 ++++++ > 3 files changed, 53 insertions(+) >=20 > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c > index ed971b4..cd34f46 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -1614,6 +1614,26 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_e= th_dev_info *dev_info) > dev_info->driver_name =3D dev->data->drv_name; > } >=20 > +int > +rte_eth_dev_get_ptype_info(uint8_t port_id, uint32_t ptype_mask, > + uint32_t ptypes[], int num) > +{ > + int ret, i, j; > + struct rte_eth_dev *dev; > + uint32_t all_ptypes[RTE_PTYPE_MAX_NUM]; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev =3D &rte_eth_devices[port_id]; > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_ptype_info_get, -ENOTSUP); > + ret =3D (*dev->dev_ops->dev_ptype_info_get)(dev, all_ptypes); > + > + for (i =3D 0, j =3D 0; i < ret && j < num; ++i) > + if (all_ptypes[i] & ptype_mask) > + ptypes[j++] =3D all_ptypes[i]; > + > + return ret; I think it needs to be something like: j =3D 0; for (i =3D 0, j =3D 0; i < ret; ++i) { if (all_ptypes[i] & ptype_mask) { if (j < num) ptypes[j] =3D all_ptypes[i]; j++; } } return j; Konstantin > +} > + > void > rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr) > { > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.= h > index bada8ad..42f8188 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -1021,6 +1021,10 @@ typedef void (*eth_dev_infos_get_t)(struct rte_eth= _dev *dev, > struct rte_eth_dev_info *dev_info); > /**< @internal Get specific informations of an Ethernet device. */ >=20 > +typedef int (*eth_dev_ptype_info_get_t)(struct rte_eth_dev *dev, > + uint32_t ptypes[]); > +/**< @internal Get ptype info of eth_rx_burst_t. */ > + > typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev, > uint16_t queue_id); > /**< @internal Start rx and tx of a queue of an Ethernet device. */ > @@ -1347,6 +1351,7 @@ struct eth_dev_ops { > eth_queue_stats_mapping_set_t queue_stats_mapping_set; > /**< Configure per queue stat counter mapping. */ > eth_dev_infos_get_t dev_infos_get; /**< Get device info. */ > + eth_dev_ptype_info_get_t dev_ptype_info_get; /** Get ptype info */ > mtu_set_t mtu_set; /**< Set MTU. */ > vlan_filter_set_t vlan_filter_set; /**< Filter VLAN Setup. */ > vlan_tpid_set_t vlan_tpid_set; /**< Outer VLAN TPID Set= up. */ > @@ -2273,6 +2278,28 @@ extern void rte_eth_dev_info_get(uint8_t port_id, > struct rte_eth_dev_info *dev_info); >=20 > /** > + * Retrieve the contextual information of an Ethernet device. > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param ptype_mask > + * A hint of what kind of packet type which the caller is interested i= n. > + * @param ptypes > + * An array of packet types to be filled with. > + * @param num > + * The size of ptypes array. > + * @return > + * - (>0) Number of ptypes supported. May be greater than param num an= d > + * caller needs to check that. > + * - (0 or -ENOTSUP) if PMD does not fill the specified ptype. > + * - (-ENODEV) if *port_id* invalid. > + */ > +extern int rte_eth_dev_get_ptype_info(uint8_t port_id, > + uint32_t ptype_mask, > + uint32_t ptypes[], > + int num); > + > +/** > * Retrieve the MTU of an Ethernet device. > * > * @param port_id > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index f234ac9..d116711 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -667,6 +667,12 @@ extern "C" { > #define RTE_PTYPE_INNER_L4_MASK 0x0f000000 >=20 > /** > + * Total number of all kinds of RTE_PTYPE_*, except from *_MASK, is 37 = for now > + * and reserve some space for new ptypes > + */ > +#define RTE_PTYPE_MAX_NUM 64 > + > +/** > * Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types= one by > * one, bit 4 is selected to be used for IPv4 only. Then checking bit 4 = can > * determine if it is an IPV4 packet. > -- > 2.1.4