From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 4135E2BAA for ; Thu, 25 Feb 2016 16:47:27 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 25 Feb 2016 07:46:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,498,1449561600"; d="scan'208";a="911165010" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by fmsmga001.fm.intel.com with ESMTP; 25 Feb 2016 07:46:29 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.237]) by IRSMSX109.ger.corp.intel.com ([169.254.13.100]) with mapi id 14.03.0248.002; Thu, 25 Feb 2016 15:46:26 +0000 From: "Ananyev, Konstantin" To: "Tan, Jianfeng" , "dev@dpdk.org" Thread-Topic: [PATCH v3 01/12] ethdev: add API to query packet type filling info Thread-Index: AQHRb9x63YVJTZ3yWkKEQ5Gzpzo6uZ882isQ Date: Thu, 25 Feb 2016 15:46:26 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725836B0B4F8@irsmsx105.ger.corp.intel.com> References: <1451544799-70776-1-git-send-email-jianfeng.tan@intel.com> <1456386842-112571-1-git-send-email-jianfeng.tan@intel.com> <1456386842-112571-2-git-send-email-jianfeng.tan@intel.com> In-Reply-To: <1456386842-112571-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-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNThmMjg4MjUtZjVkZC00M2JkLTkwZWEtNzBiNmEwYjFkYzcwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Ikw0STVkK2hJSFdvVWhkSEJTa0kwcEJCZzN6RHdDXC9IeHpYYzBXRlh3MVJNPSJ9 x-ctpclassification: CTP_IC 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 v3 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: Thu, 25 Feb 2016 15:47:27 -0000 Hi Jainfeng, >=20 > Add a new API rte_eth_dev_get_ptype_info to query whether/what packet > type can be filled by given pmd rx burst function. >=20 > Signed-off-by: Jianfeng Tan > --- > lib/librte_ether/rte_ethdev.c | 32 ++++++++++++++++++++++++++++++++ > lib/librte_ether/rte_ethdev.h | 23 +++++++++++++++++++++++ > 2 files changed, 55 insertions(+) >=20 > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c > index 1257965..b52555b 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -1576,6 +1576,38 @@ 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 **p_ptypes) > +{ > + int i, j, ret; > + struct rte_eth_dev *dev; > + const uint32_t *all_ptypes; > + > + 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); > + all_ptypes =3D (*dev->dev_ops->dev_ptype_info_get)(dev); > + > + if (!all_ptypes) > + return 0; > + > + for (i =3D 0, ret =3D 0; all_ptypes[i] !=3D RTE_PTYPE_UNKNOWN; ++i) > + if (all_ptypes[i] & ptype_mask) > + ret++; > + if (ret =3D=3D 0) > + return 0; > + > + *p_ptypes =3D (uint32_t *)malloc(sizeof(uint32_t) * ret); > + if (*p_ptypes =3D=3D NULL) > + return -ENOMEM; I thought we all agreed to follow snprintf()-like logic and avoid any memor= y allocations inside that function. So why malloc() again? Konstantin > + > + for (i =3D 0, j =3D 0; all_ptypes[i] !=3D RTE_PTYPE_UNKNOWN; ++i) > + if (all_ptypes[i] & ptype_mask) > + *p_ptypes[j++] =3D all_ptypes[i]; > + return ret; > +} > + > 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 16da821..341e2ff 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -1021,6 +1021,9 @@ 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 const uint32_t *(*eth_dev_ptype_info_get_t)(struct rte_eth_dev *= dev); > +/**< @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 +1350,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. */ > @@ -2268,6 +2272,25 @@ void rte_eth_macaddr_get(uint8_t port_id, struct e= ther_addr *mac_addr); > void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_= info); >=20 > /** > + * Retrieve the packet type 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 p_ptypes > + * A pointer to store address of adequent packet types array. Caller t= o free. > + * @return > + * - (>0) Number of ptypes supported. Need caller to free the array. > + * - (0 or -ENOTSUP) if PMD does not fill the specified ptype. > + * - (-ENOMEM) if fail to malloc required memory to store ptypes. > + * - (-ENODEV) if *port_id* invalid. > + */ > +extern int rte_eth_dev_get_ptype_info(uint8_t port_id, > + uint32_t ptype_mask, > + uint32_t **p_ptypes); > + > +/** > * Retrieve the MTU of an Ethernet device. > * > * @param port_id > -- > 2.1.4