cxgbe: add features to CXGBE PMD
cover cxgbe: add features to CXGBE PMD
This patch series add some features to CXGBE PMD.
Patch 1 fixes a bug where reading/writing PCI config space in BSD fails with EPERM due to missing write permission when opening /dev/pci/.
Patch 2 adds support to access PCI config space for CXGBE PMD.
Patch 3 programs PCIe completion timeout to 4 sec.
Patch 4 adds support to get/set EEPROM.
Patch 5 adds support to get register dump.
Rahul Lakkireddy (5):
pci: fix access to PCI config space in bsd
cxgbe: add support to access PCI config space
cxgbe: set default PCIe completion timeout
cxgbe: add support to get/set EEPROM
cxgbe: add support to get register dump
doc/guides/nics/overview.rst | 4 +- drivers/net/cxgbe/base/adapter.h | 138 ++++- drivers/net/cxgbe/base/common.h | 11 +- drivers/net/cxgbe/base/t4_hw.c | 1047 ++++++++++++++++++++++++++++++++++- drivers/net/cxgbe/base/t4_hw.h | 5 +- drivers/net/cxgbe/cxgbe_ethdev.c | 167 ++++++ lib/librte_eal/bsdapp/eal/eal_pci.c | 4 +- 7 files changed, 1368 insertions(+), 8 deletions(-)
Signature · 1 line
2.5.3
PATCH 1/5 pci: fix access to PCI config space in bsd
PCIOCREAD and PCIOCWRITE ioctls to read/write PCI config space fail with EPERM due to missing write permission. Fix by opening /dev/pci/ with O_RDWR instead.
--- lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +2 -2
@@ -422,7 +422,7 @@ int rte_eal_pci_read_config(const struct rte_pci_device *dev, goto error; } - fd =open ("/dev/pci" ,O_RDONLY ); + fd =open ("/dev/pci" ,O_RDWR );if (fd <0 ) {RTE_LOG (ERR ,EAL ,"%s(): error opening /dev/pci\n" , __func__); goto error;
@@ -466,7 +466,7 @@ int rte_eal_pci_write_config(const struct rte_pci_device *dev,memcpy (&pi.pi_data, buf, len); - fd =open ("/dev/pci" ,O_RDONLY ); + fd =open ("/dev/pci" ,O_RDWR );if (fd <0 ) {RTE_LOG (ERR ,EAL ,"%s(): error opening /dev/pci\n" , __func__); goto error;
Signature · 1 line
2.5.3
PATCH 2/5 cxgbe: add support to access PCI config space
In reply to Rahul LakkireddyAdd helper functions to access PCI config space.
--- drivers/net/cxgbe/base/adapter.h | 129 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-)
drivers/net/cxgbe/base/adapter.h +128 -1
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2014-2015 Chelsio Communications. +* Copyright(c) 2014-2016 Chelsio Communications. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -427,6 +427,133 @@ static inline void t4_write_reg64(struct adapter *adapter, u32 reg_addr,CXGBE_WRITE_REG64 (adapter, reg_addr, val); } +#define PCI_STATUS 0x06/* 16 bits */ +#define PCI_STATUS_CAP_LIST 0x10/* Support Capability List */ +#define PCI_CAPABILITY_LIST 0x34 +/* Offset of first capability list entry */ +#define PCI_CAP_LIST_ID 0/* Capability ID */ +#define PCI_CAP_LIST_NEXT 1/* Next capability in the list */ + +/** +* t4_os_pci_write_cfg4 - 32-bit write to PCI config space +* @adapter: the adapter +* @addr: the register address +* @val: the value to write +* +* Write a 32-bit value into the given register in PCI config space. +*/ +static inline void t4_os_pci_write_cfg4 (struct adapter *adapter,size_t addr, +off_t val) +{ +u32 val32 = val; + +if (rte_eal_pci_write_config (adapter->pdev, &val32,sizeof (val32), + addr) <0 ) +dev_err (adapter,"Can't write to PCI config space\n" ); +} + +/** +* t4_os_pci_read_cfg4 - read a 32-bit value from PCI config space +* @adapter: the adapter +* @addr: the register address +* @val: where to store the value read +* +* Read a 32-bit value from the given register in PCI config space. +*/ +static inline void t4_os_pci_read_cfg4 (struct adapter *adapter,size_t addr, +u32 *val) +{ +if (rte_eal_pci_read_config (adapter->pdev, val,sizeof (*val), + addr) <0 ) +dev_err (adapter,"Can't read from PCI config space\n" ); +} + +/** +* t4_os_pci_write_cfg2 - 16-bit write to PCI config space +* @adapter: the adapter +* @addr: the register address +* @val: the value to write +* +* Write a 16-bit value into the given register in PCI config space. +*/ +static inline void t4_os_pci_write_cfg2 (struct adapter *adapter,size_t addr, +off_t val) +{ +u16 val16 = val; + +if (rte_eal_pci_write_config (adapter->pdev, &val16,sizeof (val16), + addr) <0 ) +dev_err (adapter,"Can't write to PCI config space\n" ); +} + +/** +* t4_os_pci_read_cfg2 - read a 16-bit value from PCI config space +* @adapter: the adapter +* @addr: the register address +* @val: where to store the value read +* +* Read a 16-bit value from the given register in PCI config space. +*/ +static inline void t4_os_pci_read_cfg2 (struct adapter *adapter,size_t addr, +u16 *val) +{ +if (rte_eal_pci_read_config (adapter->pdev, val,sizeof (*val), + addr) <0 ) +dev_err (adapter,"Can't read from PCI config space\n" ); +} + +/** +* t4_os_pci_read_cfg - read a 8-bit value from PCI config space +* @adapter: the adapter +* @addr: the register address +* @val: where to store the value read +* +* Read a 8-bit value from the given register in PCI config space. +*/ +static inline void t4_os_pci_read_cfg (struct adapter *adapter,size_t addr, +u8 *val) +{ +if (rte_eal_pci_read_config (adapter->pdev, val,sizeof (*val), + addr) <0 ) +dev_err (adapter,"Can't read from PCI config space\n" ); +} + +/** +* t4_os_find_pci_capability - lookup a capability in the PCI capability list +* @adapter: the adapter +* @cap: the capability +* +* Return the address of the given capability within the PCI capability list. +*/ +static inline int t4_os_find_pci_capability (struct adapter *adapter,int cap) +{ +u16 status; +int ttl =48 ; +u8 pos =0 ; +u8 id =0 ; + +t4_os_pci_read_cfg2 (adapter,PCI_STATUS , &status); +if (!(status &PCI_STATUS_CAP_LIST )) { +dev_err (adapter,"PCIe capability reading failed\n" ); +return -1 ; + } + +t4_os_pci_read_cfg (adapter,PCI_CAPABILITY_LIST , &pos); +while (ttl-- && pos >=0x40 ) { + pos &= ~3 ; +t4_os_pci_read_cfg (adapter, (pos +PCI_CAP_LIST_ID ), &id); + +if (id ==0xff ) +break ; + +if (id == cap) +return (int )pos; + +t4_os_pci_read_cfg (adapter, (pos +PCI_CAP_LIST_NEXT ), &pos); + } +return 0 ; +} +/** * t4_os_set_hw_addr - store a port's MAC address in SW * @adapter: the adapter
Signature · 1 line
2.5.3
PATCH 3/5 cxgbe: set default PCIe completion timeout
In reply to Rahul LakkireddyProgram the PCIe completion timeout to 4 sec to give enough time to allow completions to be received successfully in some older systems.
--- drivers/net/cxgbe/base/adapter.h | 2 ++ drivers/net/cxgbe/base/t4_hw.c | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
drivers/net/cxgbe/base/adapter.h +2 -0
@@ -431,8 +431,10 @@ static inline void t4_write_reg64(struct adapter *adapter, u32 reg_addr,#define PCI_STATUS_CAP_LIST 0x10/* Support Capability List */ #define PCI_CAPABILITY_LIST 0x34/* Offset of first capability list entry */ +#define PCI_CAP_ID_EXP 0x10/* PCI Express */ #define PCI_CAP_LIST_ID 0/* Capability ID */ #define PCI_CAP_LIST_NEXT 1/* Next capability in the list */ +#define PCI_EXP_DEVCTL2 40/* Device Control 2 */ /** * t4_os_pci_write_cfg4 - 32-bit write to PCI config space
drivers/net/cxgbe/base/t4_hw.c +18 -1
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2014-2015 Chelsio Communications. +* Copyright(c) 2014-2016 Chelsio Communications. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -2326,6 +2326,21 @@ int t4_get_flash_params(struct adapter *adapter)return 0 ; } +static void set_pcie_completion_timeout (struct adapter *adapter, +u8 range) +{ +u32 pcie_cap; +u16 val; + + pcie_cap =t4_os_find_pci_capability (adapter,PCI_CAP_ID_EXP ); +if (pcie_cap) { +t4_os_pci_read_cfg2 (adapter, pcie_cap +PCI_EXP_DEVCTL2 , &val); + val &=0xfff0 ; + val |= range; +t4_os_pci_write_cfg2 (adapter, pcie_cap +PCI_EXP_DEVCTL2 , val); + } +} +/** * t4_prep_adapter - prepare SW and HW for operation * @adapter: the adapter
@@ -2384,6 +2399,8 @@ int t4_prep_adapter(struct adapter *adapter) adapter->params.portvec =1 ; adapter->params.vpd.cclk =50000 ; +/* Set pci completion timeout value to 4 seconds. */ +set_pcie_completion_timeout (adapter,0xd );return 0 ; }
Signature · 1 line
2.5.3
PATCH 4/5 cxgbe: add support to get/set EEPROM
In reply to Rahul LakkireddyAdd operations to get/set EEPROM.
--- doc/guides/nics/overview.rst | 2 +- drivers/net/cxgbe/base/adapter.h | 7 ++ drivers/net/cxgbe/base/common.h | 5 +- drivers/net/cxgbe/base/t4_hw.c | 182 +++++++++++++++++++++++++++++++++++++++ drivers/net/cxgbe/base/t4_hw.h | 5 +- drivers/net/cxgbe/cxgbe_ethdev.c | 142 ++++++++++++++++++++++++++++++ 6 files changed, 340 insertions(+), 3 deletions(-)
doc/guides/nics/overview.rst +1 -1
@@ -130,7 +130,7 @@ Most of these differences are summarized below. Basic stats Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Extended stats Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Stats per queue Y Y Y Y Y Y Y Y Y Y Y Y - EEPROM dump Y Y Y + EEPROM dump Y Y Y Y Registers dump Y Y Y Y Y Y Multiprocess aware Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y BSD nic_uio Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
drivers/net/cxgbe/base/adapter.h +7 -0
@@ -318,6 +318,9 @@ struct adapter {unsigned int mbox;/* associated mailbox */ unsigned int pf;/* associated physical function id */ +unsigned int vpd_busy; +unsigned int vpd_flag; +int use_unpacked_mode;/* unpacked rx mode state */ };
@@ -435,6 +438,10 @@ static inline void t4_write_reg64(struct adapter *adapter, u32 reg_addr,#define PCI_CAP_LIST_ID 0/* Capability ID */ #define PCI_CAP_LIST_NEXT 1/* Next capability in the list */ #define PCI_EXP_DEVCTL2 40/* Device Control 2 */ +#define PCI_CAP_ID_VPD 0x03/* Vital Product Data */ +#define PCI_VPD_ADDR 2/* Address to access (15 bits!) */ +#define PCI_VPD_ADDR_F 0x8000/* Write 0, 1 indicates completion */ +#define PCI_VPD_DATA 4/* 32-bits of data returned here */ /** * t4_os_pci_write_cfg4 - 32-bit write to PCI config space
drivers/net/cxgbe/base/common.h +4 -1
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2014-2015 Chelsio Communications. +* Copyright(c) 2014-2016 Chelsio Communications. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -398,4 +398,7 @@ int t4_init_sge_params(struct adapter *adapter);int t4_init_tp_params (struct adapter *adap);int t4_filter_field_shift (const struct adapter *adap,unsigned int filter_sel);int t4_handle_fw_rpl (struct adapter *adap,const __be64 *rpl); +int t4_seeprom_read (struct adapter *adapter,u32 addr,u32 *data); +int t4_seeprom_write (struct adapter *adapter,u32 addr,u32 data); +int t4_seeprom_wp (struct adapter *adapter,int enable);#endif /* __CHELSIO_COMMON_H */
drivers/net/cxgbe/base/t4_hw.c +182 -0
194 lines not on this page · raw message
drivers/net/cxgbe/base/t4_hw.h +4 -1
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2014-2015 Chelsio Communications. +* Copyright(c) 2014-2016 Chelsio Communications. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,9 @@enum {NCHAN =4 ,/* # of HW channels */ +EEPROMSIZE =17408 ,/* Serial EEPROM physical size */ +EEPROMVSIZE =32768 ,/* Serial EEPROM virtual address space size */ +EEPROMPFSIZE =1024 ,/* EEPROM writable area size for PFn, n>0 */ NMTUS =16 ,/* size of MTU table */ NCCTRL_WIN =32 ,/* # of congestion control windows */ MBOX_LEN =64 ,/* mailbox size in bytes */
drivers/net/cxgbe/cxgbe_ethdev.c +142 -0
154 lines not on this page · raw message
Signature · 1 line
2.5.3
PATCH 5/5 cxgbe: add support to get register dump
In reply to Rahul LakkireddyAdd operations to get register dump.
--- doc/guides/nics/overview.rst | 2 +- drivers/net/cxgbe/base/common.h | 6 + drivers/net/cxgbe/base/t4_hw.c | 846 +++++++++++++++++++++++++++++++++++++++ drivers/net/cxgbe/cxgbe_ethdev.c | 25 ++ 4 files changed, 878 insertions(+), 1 deletion(-)
doc/guides/nics/overview.rst +1 -1
@@ -131,7 +131,7 @@ Most of these differences are summarized below. Extended stats Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Stats per queue Y Y Y Y Y Y Y Y Y Y Y Y EEPROM dump Y Y Y Y - Registers dump Y Y Y Y Y Y + Registers dump Y Y Y Y Y Y Y Multiprocess aware Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y BSD nic_uio Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Linux UIO Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
drivers/net/cxgbe/base/common.h +6 -0
@@ -50,6 +50,10 @@ enum { };enum { +T5_REGMAP_SIZE = (332 *1024 ), +}; + +enum {MEMWIN0_APERTURE =2048 ,MEMWIN0_BASE =0x1b800 , };
@@ -398,6 +402,8 @@ int t4_init_sge_params(struct adapter *adapter);int t4_init_tp_params (struct adapter *adap);int t4_filter_field_shift (const struct adapter *adap,unsigned int filter_sel);int t4_handle_fw_rpl (struct adapter *adap,const __be64 *rpl); +unsigned int t4_get_regs_len (struct adapter *adap); +void t4_get_regs (struct adapter *adap,void *buf,size_t buf_size);int t4_seeprom_read (struct adapter *adapter,u32 addr,u32 *data);int t4_seeprom_write (struct adapter *adapter,u32 addr,u32 data);int t4_seeprom_wp (struct adapter *adapter,int enable);
drivers/net/cxgbe/base/t4_hw.c +846 -0
852 lines not on this page · raw message
drivers/net/cxgbe/cxgbe_ethdev.c +25 -0
@@ -920,6 +920,29 @@ out:return err; } +static int cxgbe_get_regs_len (struct rte_eth_dev *eth_dev) +{ +struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); +struct adapter *adapter = pi->adapter; + +return t4_get_regs_len (adapter) /sizeof (uint32_t ); +} + +static int cxgbe_get_regs (struct rte_eth_dev *eth_dev, +struct rte_dev_reg_info *regs) +{ +struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); +struct adapter *adapter = pi->adapter; + + regs->length =cxgbe_get_regs_len (eth_dev); + regs->version =CHELSIO_CHIP_VERSION (adapter->params.chip) | + (CHELSIO_CHIP_RELEASE (adapter->params.chip) <<10 ) | + (1 <<16 ); +t4_get_regs (adapter, regs->data, (regs->length *sizeof (uint32_t ))); + +return 0 ; +} +static const struct eth_dev_ops cxgbe_eth_dev_ops = { .dev_start = cxgbe_dev_start, .dev_stop = cxgbe_dev_stop,
@@ -948,6 +971,8 @@ static const struct eth_dev_ops cxgbe_eth_dev_ops = { .get_eeprom_length = cxgbe_get_eeprom_length, .get_eeprom = cxgbe_get_eeprom, .set_eeprom = cxgbe_set_eeprom, + .get_reg_length = cxgbe_get_regs_len, + .get_reg = cxgbe_get_regs, };/*
Signature · 1 line
2.5.3
Re: [PATCH 1/5] pci: fix access to PCI config space in bsd
In reply to Rahul LakkireddyQuoted 27 lines · Rahul Lakkireddy
PCIOCREAD and PCIOCWRITE ioctls to read/write PCI config space fail with EPERM due to missing write permission. Fix by opening
/dev/pci/withO_RDWRinstead.Fixes 632b2d1deeed ("eal: provide functions to access PCI config")Signed-off-by Rahul Lakkireddy <[email protected]>Signed-off-by Kumar Sanghvi <[email protected]>--- lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/bsdapp/eal/eal_pci.c +1
-1@@ -422,7 +422,7 @@ int rte_eal_pci_read_config(const struct rte_pci_device *dev, goto error; } - fd =open ("/dev/pci" ,O_RDONLY ); + fd =open ("/dev/pci" ,O_RDWR );if (fd <0 ) {RTE_LOG (ERR ,EAL ,"%s(): error opening /dev/pci\n" , __func__); goto error;
lib/librte_eal/bsdapp/eal/eal_pci.c int rte_eal_pci_write_config(const struct rte_pci_device *dev, · line 472
Quoted 8 lines
lib/librte_eal/bsdapp/eal/eal_pci.c +1
-1@@ -466,7 +466,7 @@ int rte_eal_pci_write_config(const struct rte_pci_device *dev,memcpy (&pi.pi_data, buf, len); - fd =open ("/dev/pci" ,O_RDONLY ); + fd =open ("/dev/pci" ,O_RDWR );if (fd <0 ) {RTE_LOG (ERR ,EAL ,"%s(): error opening /dev/pci\n" , __func__); goto error;
Does the read function as well as the write one need O_RDWR permissions? There is also an ioctl in rte_eal_pci_scan which operates on a RDONLY file descriptor. Does that need to be modified also?
/Bruce
Re: [PATCH 1/5] pci: fix access to PCI config space in bsd
Hi Bruce,
Quoted 30 lines · Bruce Richardson
Quoted 29 lines · Rahul Lakkireddy
PCIOCREAD and PCIOCWRITE ioctls to read/write PCI config space fail with EPERM due to missing write permission. Fix by opening
/dev/pci/withO_RDWRinstead.Fixes 632b2d1deeed ("eal: provide functions to access PCI config")Signed-off-by Rahul Lakkireddy <[email protected]>Signed-off-by Kumar Sanghvi <[email protected]>--- lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/bsdapp/eal/eal_pci.c +1
-1@@ -422,7 +422,7 @@ int rte_eal_pci_read_config(const struct rte_pci_device *dev, goto error; } - fd =open ("/dev/pci" ,O_RDONLY ); + fd =open ("/dev/pci" ,O_RDWR );if (fd <0 ) {RTE_LOG (ERR ,EAL ,"%s(): error opening /dev/pci\n" , __func__); goto error;@@ -466,7 +466,7 @@ int rte_eal_pci_write_config(const struct rte_pci_device *dev,memcpy (&pi.pi_data, buf, len);
Quoted 9 lines
lib/librte_eal/bsdapp/eal/eal_pci.c int rte_eal_pci_read_config(const struct rte_pci_device *dev, · line 428
Quoted 6 lines
lib/librte_eal/bsdapp/eal/eal_pci.c +1
-1- fd =open ("/dev/pci" ,O_RDONLY ); + fd =open ("/dev/pci" ,O_RDWR );if (fd <0 ) {RTE_LOG (ERR ,EAL ,"%s(): error opening /dev/pci\n" , __func__); goto error;Does the read function as well as the write one need
O_RDWRpermissions? There is also an ioctl inrte_eal_pci_scanwhich operates on a RDONLY file descriptor. Does that need to be modified also?
Yes, both PCIOCREAD and PCIOCWRITE ioctls seem to require write permission. Otherwise, pci_ioctl [1] seems to return EPERM. On the other hand, the PCIOCGETCONF ioctl used in rte_eal_pci_scan doesn't seem to require a write permission. So, it should be fine to leave it as RDONLY.
Thanks,
Rahul
Bruce Richardson
AppliedQuoted 11 lines · Rahul Lakkireddy
This patch series add some features to CXGBE PMD.
Patch 1 fixes a bug where reading/writing PCI config space in BSD fails with EPERM due to missing write permission when opening
/dev/pci/.Patch 2 adds support to access PCI config space for CXGBE PMD.
Patch 3 programs PCIe completion timeout to 4 sec.
Patch 4 adds support to get/set EEPROM.
Quoted 9 lines
Patch 5 adds support to get register dump.
Rahul Lakkireddy (5):
pci: fix access to PCI config space in bsd
cxgbe: add support to access PCI config space
cxgbe: set default PCIe completion timeout
cxgbe: add support to get/set EEPROM
cxgbe: add support to get register dump
Applied to dpdk-next-net/rel_16_07
/Bruce