Hi, > -----Original Message----- > From: Yigit, Ferruh > Sent: Wednesday, March 06, 2019 20:31 > To: Xu, Rosen <rosen...@intel.com>; dev@dpdk.org > Cc: Zhang, Tianfei <tianfei.zh...@intel.com>; Wei, Dan > <dan....@intel.com>; Pei, Andy <andy....@intel.com>; Yang, Qiming > <qiming.y...@intel.com>; Wang, Haiyue <haiyue.w...@intel.com>; Chen, > Santos <santos.c...@intel.com>; Zhang, Zhang <zhang.zh...@intel.com>; > Hemant Agrawal <hemant.agra...@nxp.com>; Shreyansh Jain > <shreyansh.j...@nxp.com> > Subject: Re: [PATCH v1 04/11] drivers/raw/ifpga_rawdev: add IPN3KE > support for IFPGA Rawdev > > On 2/28/2019 7:13 AM, Rosen Xu wrote: > > Add Intel FPGA Acceleration NIC IPN3KE support for IFPGA Rawdev. > > > > Signed-off-by: Rosen Xu <rosen...@intel.com> > > Signed-off-by: Tianfei Zhang <tianfei.zh...@intel.com> > > Signed-off-by: Andy Pei <andy....@intel.com> > <...> > > > +static int > > +ifgpa_rawdev_get_attr(struct rte_rawdev *dev, > > + const char *attr_name, > > + uint64_t *attr_value) > > +{ > > + struct ifpga_rawdev_mac_info *mac_info; > > + struct ifpga_rawdevg_retimer_info *retimer_info; > > + struct opae_retimer_info or_info; > > + struct opae_adapter *adapter; > > + struct opae_manager *mgr; > > + struct ifpga_rawdevg_link_info *linfo; > > + struct opae_retimer_status rstatus; > > + > > + IFPGA_RAWDEV_PMD_FUNC_TRACE(); > > + > > + if (!dev || !attr_name || !attr_value) { > > + IFPGA_BUS_ERR("Invalid arguments for getting attributes"); > > + return -1; > > + } > > + > > + adapter = ifpga_rawdev_get_priv(dev); > > + if (!adapter) > > + return -1; > > + > > + mgr = opae_adapter_get_mgr(adapter); > > + if (!mgr) > > + return -1; > > + > > + if (!strcmp(attr_name, "retimer_info")) { > > + retimer_info = (struct ifpga_rawdevg_retimer_info > *)attr_value; > > How you are using the 'get_attr' & 'set_attr' is a little odd. > > I think the intention with these APIs to provide a map/dictionary like data > structure, save/get 'attr_values' by 'attr_name'. > > How you are using is, instead of getting 'attr_value', you are passing valid > pointers via 'attr_value' and make this function to fill that struct. Why you > don't have a specific function for this purpose instead of using 'get_attr' & > 'set_attr' ops? I believe this will be source of confusion in long term. >
Good suggestions, I will modify it in v2 patch set. > > + if (opae_manager_get_retimer_info(mgr, &or_info)) > > + return -1; > > + > > + retimer_info->retimer_num = or_info.num_retimer; > > + retimer_info->port_num = or_info.num_port; > > + switch (or_info.support_speed) { > > + case MXD_10GB: > > + retimer_info->mac_type = > > + IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI; > > + break; > > + case MXD_25GB: > > + retimer_info->mac_type = > > + IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI; > > + break; > > + case MXD_40GB: > > + retimer_info->mac_type = > > + IFPGA_RAWDEVG_RETIMER_MAC_TYPE_40GE_XLAUI; > > + break; > > + case MXD_100GB: > > + retimer_info->mac_type = > > + IFPGA_RAWDEV_RETIMER_MAC_TYPE_100GE_CAUI; > > + break; > > + default: > > + retimer_info->mac_type = > > + IFPGA_RAWDEV_RETIMER_MAC_TYPE_UNKNOWN; > > + break; > > + } > > + return 0; > > + } else if (!strcmp(attr_name, "default_mac")) { > > + /* not implement by MAX */ > > + mac_info = (struct ifpga_rawdev_mac_info *)attr_value; > > + mac_info->addr.addr_bytes[0] = 0; > > + mac_info->addr.addr_bytes[1] = 0; > > + mac_info->addr.addr_bytes[2] = 0; > > + mac_info->addr.addr_bytes[3] = 0; > > + mac_info->addr.addr_bytes[4] = 0; > > + mac_info->addr.addr_bytes[5] = 0xA + mac_info->port_id; > > + > > + return 0; > > + } else if (!strcmp(attr_name, "retimer_linkstatus")) { > > + linfo = (struct ifpga_rawdevg_link_info *)attr_value; > > + linfo->link_up = 0; > > + linfo->link_speed = IFPGA_RAWDEV_LINK_SPEED_UNKNOWN; > > + > > + if (opae_manager_get_retimer_status(mgr, linfo->port, > &rstatus)) > > + return -1; > > + > > + linfo->link_up = rstatus.line_link; > > + switch (rstatus.speed) { > > + case MXD_10GB: > > + linfo->link_speed = > > + IFPGA_RAWDEV_LINK_SPEED_10GB; > > + break; > > + case MXD_25GB: > > + linfo->link_speed = > > + IFPGA_RAWDEV_LINK_SPEED_25GB; > > + break; > > + case MXD_40GB: > > + linfo->link_speed = > > + IFPGA_RAWDEV_LINK_SPEED_40GB; > > + break; > > + default: > > + linfo->link_speed = > > + IFPGA_RAWDEV_LINK_SPEED_UNKNOWN; > > + break; > > + } > > + > > + return 0; > > + } else > > + return -1; > > + > > + /* Attribute not found */ > > + return -1; > > +} > > + > > +static int ifgpa_rawdev_set_attr(struct rte_rawdev *dev, > > + const char *attr_name, > > + const uint64_t attr_value) > > +{ > > + struct opae_adapter *adapter; > > + struct opae_manager *mgr; > > + /*struct ifpga_rawdevg_link_info *linfo;*/ > > + /*struct opae_retimer_status rstatus;*/ > > Please remove commented out code. Applied. > > + > > + IFPGA_RAWDEV_PMD_FUNC_TRACE(); > > + > > + if (!dev || !attr_name) { > > + IFPGA_BUS_ERR("Invalid arguments for setting attributes"); > > + return -1; > > + } > > + > > + adapter = ifpga_rawdev_get_priv(dev); > > + if (!adapter) > > + return -1; > > + > > + mgr = opae_adapter_get_mgr(adapter); > > + if (!mgr) > > + return -1; > > nothing done with 'adapter' & 'mgr' ? Why getting them? Currently we are not using set_attr, I will remove it. > > + > > + if (!strcmp(attr_name, "retimer_linkstatus")) > > + printf("ifgpa_rawdev_set_attr_func %lx\n", attr_value); > > %lx usage is wrong for 32bits, it is giving a build warning [1], also please > don't > use 'printf' for logging. Fixed in v2 patch. > And why there is a specific check for a value and log, in a generic function > like > set_attr? Currently we are not using set_attr, I will remove it. > [1] > .../drivers/raw/ifpga_rawdev/ifpga_rawdev.c: In function > ‘ifgpa_rawdev_set_attr’: > .../drivers/raw/ifpga_rawdev/ifpga_rawdev.c:465:40: error: format ‘%lx’ > expects argument of type ‘long unsigned int’, but argument 2 has type > ‘uint64_t’ {aka ‘const long long unsigned int’} [-We$ ror=format=] > printf("ifgpa_rawdev_set_attr_func %lx\n", attr_value); > ~~^ ~~~~~~~~~~ > %llx It's just for debug. Currently we are not using set_attr, I will remove it. > > + > > + return -1; > > Will function always fail? > And are you aware the you did not set anything in this function? Just ignored > the 'attr_value'? > > <...> Currently we are not using set_attr, I will remove it. > > @@ -419,7 +559,7 @@ > > > > rawdev->dev_ops = &ifpga_rawdev_ops; > > rawdev->device = &pci_dev->device; > > - rawdev->driver_name = pci_dev->device.driver->name; > > + rawdev->driver_name = pci_dev->driver->driver.name; > > They are both same right? Yes, they are same. > <...> > > > + > > +#include <rte_ether.h> > > + > > +#ifndef ETH_ALEN > > +#define ETH_ALEN 6 > > +#endif > > You can use "ETHER_ADDR_LEN" instead, it is defined in above included > 'rte_ether.h' header. Thanks, I will replace " ETH_ALEN " with "ETHER_ADDR_LEN".