On 9/26/2019 3:02 PM, Wei Hu (Xavier) wrote: > This patch adds get_reg related function codes for hns3 PMD driver. > > Signed-off-by: Wei Hu (Xavier) <xavier.hu...@huawei.com> > Signed-off-by: Chunsong Feng <fengchuns...@huawei.com> > Signed-off-by: Min Hu (Connor) <humi...@huawei.com> > Signed-off-by: Hao Chen <chenhao...@huawei.com> > Signed-off-by: Huisong Li <lihuis...@huawei.com>
<...> > +static int > +hns3_get_32_bit_regs(struct hns3_hw *hw, uint32_t regs_num, void *data) > +{ > +#define HNS3_32_BIT_REG_RTN_DATANUM 8 > +#define HNS3_32_BIT_DESC_NODATA_LEN 2 > + struct hns3_cmd_desc *desc; > + uint32_t *reg_val = data; > + uint32_t *desc_data; > + int cmd_num; > + int i, k, n; > + int ret; > + > + if (regs_num == 0) > + return 0; > + > + cmd_num = DIV_ROUND_UP(regs_num + HNS3_32_BIT_DESC_NODATA_LEN, > + HNS3_32_BIT_REG_RTN_DATANUM); > + desc = rte_zmalloc("hns3-32bit-regs", > + sizeof(struct hns3_cmd_desc) * cmd_num, 0); > + if (desc == NULL) { > + hns3_err(hw, "Failed to allocate %" PRIx64 " bytes needed to " > + "store 32bit regs", > + sizeof(struct hns3_cmd_desc) * cmd_num); 'PRIx64' won't work with 'sizeof' because its return type changes with the arch, need to use %zx with 'sizeof' I am aware that driver doesn't support 32-bits, but build is only broken because of the format errors in the log formatting, I am for fixing them. Also using correct format type is good practice. There are following related errors [1], I am fixing them while merging [2] please let me know if you request any change in the updated code. [1] .../drivers/net/hns3/hns3_regs.c(167): error #181: argument of type "unsigned int" is incompatible with format "%llx", expecting argument of type "unsigned long long" hns3_err(hw, "Failed to allocate %" PRIx64 " bytes needed to " ^ .../drivers/net/hns3/hns3_regs.c(224): error #181: argument of type "unsigned int" is incompatible with format "%llx", expecting argument of type "unsigned long long" hns3_err(hw, "Failed to allocate %" PRIx64 " bytes needed to " ^ .../drivers/net/hns3/hns3_ethdev_vf.c(1625): error #181: argument of type "unsigned int" is incompatible with format "%llx", expecting argument of type "unsigned long long" PMD_INIT_LOG(ERR, "Failed to allocate %" PRIx64 " bytes needed " ^ .../drivers/net/hns3/hns3_rxtx.c(643): error #181: argument of type "uint64_t={__uint64_t={unsigned long long}}" is incompatible with format "%lx", expecting argument of type "unsigned long" hns3_dbg(hw, "No.%d rx descriptors iova 0x%lx", idx, ^ .../drivers/net/hns3/hns3_rxtx.c(1085): error #181: argument of type "uint64_t={__uint64_t={unsigned long long}}" is incompatible with format "%lx", expecting argument of type "unsigned long" hns3_dbg(hw, "No.%d tx descriptors iova 0x%lx", idx, ^ .../drivers/net/hns3/hns3_ethdev.c(4837): error #181: argument of type "unsigned int" is incompatible with format "%llx", expecting argument of type "unsigned long long" PMD_INIT_LOG(ERR, "Failed to allocate %" PRIx64 " bytes needed " ^ [2] diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 574eb9204..862a717fd 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -4834,7 +4834,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) sizeof(struct rte_ether_addr) * HNS3_UC_MACADDR_NUM, 0); if (eth_dev->data->mac_addrs == NULL) { - PMD_INIT_LOG(ERR, "Failed to allocate %" PRIx64 " bytes needed " + PMD_INIT_LOG(ERR, "Failed to allocate %zx bytes needed " "to store MAC addresses", sizeof(struct rte_ether_addr) * HNS3_UC_MACADDR_NUM); diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 07a4b01d6..121beb58d 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1622,7 +1622,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) sizeof(struct rte_ether_addr) * HNS3_VF_UC_MACADDR_NUM, 0); if (eth_dev->data->mac_addrs == NULL) { - PMD_INIT_LOG(ERR, "Failed to allocate %" PRIx64 " bytes needed " + PMD_INIT_LOG(ERR, "Failed to allocate %zx bytes needed " "to store MAC addresses", sizeof(struct rte_ether_addr) * HNS3_VF_UC_MACADDR_NUM); diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c index d83eef339..23405030e 100644 --- a/drivers/net/hns3/hns3_regs.c +++ b/drivers/net/hns3/hns3_regs.c @@ -164,7 +164,7 @@ hns3_get_32_bit_regs(struct hns3_hw *hw, uint32_t regs_num, void *data) desc = rte_zmalloc("hns3-32bit-regs", sizeof(struct hns3_cmd_desc) * cmd_num, 0); if (desc == NULL) { - hns3_err(hw, "Failed to allocate %" PRIx64 " bytes needed to " + hns3_err(hw, "Failed to allocate %zx bytes needed to " "store 32bit regs", sizeof(struct hns3_cmd_desc) * cmd_num); return -ENOMEM; @@ -221,7 +221,7 @@ hns3_get_64_bit_regs(struct hns3_hw *hw, uint32_t regs_num, void *data) desc = rte_zmalloc("hns3-64bit-regs", sizeof(struct hns3_cmd_desc) * cmd_num, 0); if (desc == NULL) { - hns3_err(hw, "Failed to allocate %" PRIx64 " bytes needed to " + hns3_err(hw, "Failed to allocate %zx bytes needed to " "store 64bit regs", sizeof(struct hns3_cmd_desc) * cmd_num); return -ENOMEM; diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index b29d98a2f..184b8e4b6 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -640,7 +640,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, rxq->rx_ring = (struct hns3_desc *)rx_mz->addr; rxq->rx_ring_phys_addr = rx_mz->iova; - hns3_dbg(hw, "No.%d rx descriptors iova 0x%lx", idx, + hns3_dbg(hw, "No.%d rx descriptors iova 0x%" PRIx64, idx, rxq->rx_ring_phys_addr); rxq->next_to_use = 0; @@ -1082,7 +1082,7 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, txq->tx_ring = (struct hns3_desc *)tx_mz->addr; txq->tx_ring_phys_addr = tx_mz->iova; - hns3_dbg(hw, "No.%d tx descriptors iova 0x%lx", idx, + hns3_dbg(hw, "No.%d tx descriptors iova 0x%" PRIx64, idx, txq->tx_ring_phys_addr); /* Clear tx bd */