net/zxdh: possible changes
cover net/zxdh: possible changes
Reviewing zxdh driver these are some obvious things that could be fixed
Stephen Hemminger (5):
net/zxdh: remove __rte_unused from function prototypes net/zxdh: remove __rte_unused attribute net/zxdh: fix RTE_ASSERT expression
net/zxdh: make callback table const and static net/zxdh: fix indentation in mtr get and use assign
drivers/net/zxdh/zxdh_ethdev.c | 2 +- drivers/net/zxdh/zxdh_ethdev_ops.c | 2 +- drivers/net/zxdh/zxdh_ethdev_ops.h | 10 ++++------ drivers/net/zxdh/zxdh_msg.c | 24 ++++++++++-------------- drivers/net/zxdh/zxdh_msg.h | 1 - drivers/net/zxdh/zxdh_mtr.c | 30 +++++++++++++++--------------- drivers/net/zxdh/zxdh_mtr.h | 4 ++-- drivers/net/zxdh/zxdh_np.h | 2 +- drivers/net/zxdh/zxdh_queue.h | 4 ++-- drivers/net/zxdh/zxdh_rxtx.h | 6 ++---- 10 files changed, 38 insertions(+), 47 deletions(-)
Signature · 1 line
2.47.2
RFC 1/5 net/zxdh: remove __rte_unused from function prototypes
The unused attribute needs to be used on the function definition only. It is meaningless on function prototype.
--- drivers/net/zxdh/zxdh_ethdev_ops.h | 10 ++++------ drivers/net/zxdh/zxdh_mtr.h | 4 ++-- drivers/net/zxdh/zxdh_np.h | 2 +- drivers/net/zxdh/zxdh_queue.h | 4 ++-- drivers/net/zxdh/zxdh_rxtx.h | 6 ++---- 5 files changed, 11 insertions(+), 15 deletions(-)
drivers/net/zxdh/zxdh_ethdev_ops.h +4 -6
@@ -74,7 +74,7 @@ struct zxdh_hw_vqm_stats {int zxdh_dev_set_link_up (struct rte_eth_dev *dev);int zxdh_dev_set_link_down (struct rte_eth_dev *dev); -int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused); +int32_t zxdh_dev_link_update (struct rte_eth_dev *dev,int32_t wait_to_complete);int zxdh_dev_mac_addr_add (struct rte_eth_dev *dev,struct rte_ether_addr *mac_addr,uint32_t index,uint32_t vmdq);int zxdh_dev_mac_addr_set (struct rte_eth_dev *dev,struct rte_ether_addr *mac_addr);
@@ -101,13 +101,11 @@ int zxdh_hw_np_stats_pf_reset(struct rte_eth_dev *dev, uint32_t stats_id);void zxdh_data_hi_to_lo (uint64_t *data);int32_t zxdh_dev_xstats_get (struct rte_eth_dev *dev,struct rte_eth_xstat *xstats,uint32_t n);int32_t zxdh_dev_xstats_get_names (struct rte_eth_dev *dev, -struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned int limit); -int zxdh_dev_fw_version_get (struct rte_eth_dev *dev,char *fw_version, - size_t fw_size __rte_unused); +struct rte_eth_xstat_name *xstats_names,unsigned int limit); +int zxdh_dev_fw_version_get (struct rte_eth_dev *dev,char *fw_version,size_t fw_size);int zxdh_dev_get_module_info (struct rte_eth_dev *dev,struct rte_eth_dev_module_info *modinfo);int zxdh_dev_get_module_eeprom (struct rte_eth_dev *dev,struct rte_dev_eeprom_info *info); -int zxdh_meter_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg); +int zxdh_meter_ops_get (struct rte_eth_dev *dev,void *arg);#endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_mtr.h +2 -2
@@ -100,8 +100,8 @@ struct zxdh_hw_mtr_stats {uint32_t n_bytes_dropped_lo; }; -int zxdh_meter_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg); -void zxdh_mtr_release(struct rte_eth_dev *dev __rte_unused); +int zxdh_meter_ops_get (struct rte_eth_dev *dev,void *arg); +void zxdh_mtr_release (struct rte_eth_dev *dev);void zxdh_mtr_policy_res_free (struct rte_mempool *mtr_policy_mp,struct zxdh_meter_policy *policy); int zxdh_hw_profile_unref(struct rte_eth_dev *dev, uint8_t car_type,
drivers/net/zxdh/zxdh_np.h +1 -1
@@ -824,7 +824,7 @@ uint32_t zxdh_np_car_profile_id_add(uint32_t vport_id, uint32_t flags, uint64_t *p_profile_id); -uint32_t zxdh_np_car_profile_cfg_set(__rte_unused uint32_t vport_id, +uint32_t zxdh_np_car_profile_cfg_set(uint32_t vport_id, uint32_t car_type, uint32_t pkt_sign, uint32_t profile_id,
drivers/net/zxdh/zxdh_queue.h +2 -2
@@ -410,12 +410,12 @@ int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);int32_t zxdh_dev_tx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc, - uint32_t socket_id __rte_unused, +uint32_t socket_id,const struct rte_eth_txconf *tx_conf);int32_t zxdh_dev_rx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc, - uint32_t socket_id __rte_unused, +uint32_t socket_id,const struct rte_eth_rxconf *rx_conf,struct rte_mempool *mp);int32_t zxdh_dev_rx_queue_intr_disable (struct rte_eth_dev *dev,uint16_t queue_id);
drivers/net/zxdh/zxdh_rxtx.h +2 -4
@@ -73,9 +73,7 @@ struct __rte_cache_aligned zxdh_virtnet_tx { };uint16_t zxdh_xmit_pkts_packed (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts); -uint16_t zxdh_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts, -uint16_t nb_pkts); -uint16_t zxdh_recv_pkts_packed (void *rx_queue,struct rte_mbuf **rx_pkts, -uint16_t nb_pkts); +uint16_t zxdh_xmit_pkts_prepare (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +uint16_t zxdh_recv_pkts_packed (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts);#endif /* ZXDH_RXTX_H */
Signature · 1 line
2.47.2
RFC 2/5 net/zxdh: remove __rte_unused attribute
In reply to Stephen HemmingerThese are all function arguments that are used but incorrectly labeled as unused.
--- drivers/net/zxdh/zxdh_ethdev.c | 2 +- drivers/net/zxdh/zxdh_ethdev_ops.c | 2 +- drivers/net/zxdh/zxdh_msg.c | 20 ++++++++------------ drivers/net/zxdh/zxdh_mtr.c | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +1 -1
@@ -1465,7 +1465,7 @@ zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw) }static inline int -zxdh_dtb_dump_res_init(struct zxdh_hw *hw __rte_unused, ZXDH_DEV_INIT_CTRL_T *dpp_ctrl) +zxdh_dtb_dump_res_init (struct zxdh_hw *hw,ZXDH_DEV_INIT_CTRL_T *dpp_ctrl) {int ret =0 , i;
drivers/net/zxdh/zxdh_ethdev_ops.c +1 -1
@@ -564,7 +564,7 @@ zxdh_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,return 0 ; } -void zxdh_dev_mac_addr_remove(struct rte_eth_dev *dev __rte_unused, uint32_t index __rte_unused) +void zxdh_dev_mac_addr_remove (struct rte_eth_dev *dev,uint32_t index) {struct zxdh_hw *hw = dev->data->dev_private;struct zxdh_msg_info msg_info = {0 };
drivers/net/zxdh/zxdh_msg.c +8 -12
@@ -1245,8 +1245,7 @@ zxdh_vf_promisc_uninit(struct zxdh_hw *hw, union zxdh_virport_num vport)static int zxdh_vf_port_init (struct zxdh_hw *pf_hw,uint16_t vport,void *cfg_data, - struct zxdh_msg_reply_body *res_info __rte_unused, - uint16_t *res_len __rte_unused) +struct zxdh_msg_reply_body *res_info,uint16_t *res_len) {struct zxdh_port_attr_table port_attr = {0 };union zxdh_virport_num port = {.vport = vport};
@@ -1312,8 +1311,7 @@ zxdh_mac_clear(struct zxdh_hw *hw, union zxdh_virport_num vport)static int zxdh_vf_port_uninit (struct zxdh_hw *pf_hw, uint16_t vport, void *cfg_data __rte_unused, - struct zxdh_msg_reply_body *res_info __rte_unused, - uint16_t *res_len __rte_unused) +struct zxdh_msg_reply_body *res_info,uint16_t *res_len) {char str[ZXDH_MSG_REPLY_BODY_MAX_LEN ] ="uninit" ;struct zxdh_port_attr_table port_attr = {0 };
@@ -1674,7 +1672,7 @@ zxdh_vf_rss_table_get(struct zxdh_hw *hw, uint16_t vport, void *cfg_data __rte_ustatic int zxdh_vf_port_attr_set (struct zxdh_hw *pf_hw,uint16_t vport,void *cfg_data, - struct zxdh_msg_reply_body *res_info __rte_unused, uint16_t *res_len __rte_unused) +struct zxdh_msg_reply_body *res_info,uint16_t *res_len) {RTE_ASSERT (!cfg_data || !pf_hw);if (res_info)
@@ -1735,10 +1733,8 @@ zxdh_vf_port_attr_set(struct zxdh_hw *pf_hw, uint16_t vport, void *cfg_data, }static int -zxdh_vf_np_stats_update (struct zxdh_hw *pf_hw,uint16_t vport, - void *cfg_data __rte_unused, - struct zxdh_msg_reply_body *res_info __rte_unused, - uint16_t *res_len __rte_unused) +zxdh_vf_np_stats_update (struct zxdh_hw *pf_hw,uint16_t vport,void *cfg_data, +struct zxdh_msg_reply_body *res_info,uint16_t *res_len) {struct zxdh_np_stats_updata_msg *np_stats_query = (struct zxdh_np_stats_updata_msg *)cfg_data;
@@ -1876,7 +1872,7 @@ zxdh_vf_np_stats_update(struct zxdh_hw *pf_hw, uint16_t vport, }static int -zxdh_vf_mtr_hw_stats_get(struct zxdh_hw *pf_hw __rte_unused, +zxdh_vf_mtr_hw_stats_get (struct zxdh_hw *pf_hw,uint16_t vport,void *cfg_data,struct zxdh_msg_reply_body *res_info,uint16_t *res_len)
@@ -1908,7 +1904,7 @@ zxdh_vf_mtr_hw_stats_get(struct zxdh_hw *pf_hw __rte_unused, } static int -zxdh_vf_mtr_hw_profile_add(struct zxdh_hw *pf_hw __rte_unused, +zxdh_vf_mtr_hw_profile_add(struct zxdh_hw *pf_hw, uint16_t vport, void *cfg_data, struct zxdh_msg_reply_body *res_info,
@@ -2111,7 +2107,7 @@ zxdh_config_process_callback(struct zxdh_hw *hw, struct zxdh_msg_info *msg_info,static int pf_recv_bar_msg (void *pay_load,uint16_t len,void *reps_buffer, - uint16_t *reps_len, void *eth_dev __rte_unused) +uint16_t *reps_len,void *eth_dev) {struct zxdh_msg_info *msg_info = (struct zxdh_msg_info *)pay_load;struct zxdh_msg_reply_body *reply_body = reps_buffer;
drivers/net/zxdh/zxdh_mtr.c +1 -1
@@ -1192,7 +1192,7 @@ zxdh_meter_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg) }void -zxdh_mtr_release(struct rte_eth_dev *dev __rte_unused) +zxdh_mtr_release (struct rte_eth_dev *dev) {struct zxdh_hw *priv = dev->data->dev_private;struct zxdh_meter_profile *profile;
Signature · 1 line
2.47.2
RFC 3/5 net/zxdh: fix RTE_ASSERT expression
In reply to Stephen HemmingerThe parameter in RTE_ASSERT() was incorrect.
--- drivers/net/zxdh/zxdh_msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/zxdh/zxdh_msg.c +1 -1
@@ -1445,7 +1445,7 @@ zxdh_vf_promisc_set(struct zxdh_hw *hw, uint16_t vport, void *cfg_data,struct zxdh_port_promisc_msg *promisc_msg = (struct zxdh_port_promisc_msg *)cfg_data;int ret =0 ; -RTE_ASSERT (!cfg_data || !hw || !res_info || !res_len); +RTE_ASSERT (!cfg_data || !hw || !reply || !res_len);if (promisc_msg->mode ==ZXDH_PROMISC_MODE ) {zxdh_dev_unicast_table_set (hw, vport, promisc_msg->value);
Signature · 1 line
2.47.2
RFC 4/5 net/zxdh: make callback table const and static
In reply to Stephen HemmingerTables of function pointers should be const, and since only used in one file can be marked static.
--- drivers/net/zxdh/zxdh_msg.c | 2 +- drivers/net/zxdh/zxdh_msg.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/zxdh/zxdh_msg.c +1 -1
@@ -2055,7 +2055,7 @@ zxdh_vf_mtr_hw_profile_cfg(struct zxdh_hw *pf_hw __rte_unused,return 0 ; } -zxdh_msg_process_callback zxdh_proc_cb[] = { +static const zxdh_msg_process_callback zxdh_proc_cb[] = { [ZXDH_NULL ] =NULL , [ZXDH_VF_PORT_INIT ] = zxdh_vf_port_init, [ZXDH_VF_PORT_UNINIT ] = zxdh_vf_port_uninit,
drivers/net/zxdh/zxdh_msg.h +0 -1
@@ -527,7 +527,6 @@ typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len, void *reps_buffer, uint16_t *reps_len, void *dev);typedef int (*zxdh_msg_process_callback )(struct zxdh_hw *hw,uint16_t vport,void *cfg_data,struct zxdh_msg_reply_body *res_info,uint16_t *res_len); -extern zxdh_msg_process_callback zxdh_proc_cb[];typedef int (*zxdh_bar_chan_msg_recv_callback )(void *pay_load,uint16_t len,void *reps_buffer,uint16_t *reps_len,void *dev);
Signature · 1 line
2.47.2
RFC 5/5 net/zxdh: fix indentation in mtr get and use assign
In reply to Stephen HemmingerFix the indentation of the initialized structure and use assignment instead of memcpy
--- drivers/net/zxdh/zxdh_mtr.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/net/zxdh/zxdh_mtr.c +14 -14
@@ -151,22 +151,22 @@ zxdh_meter_cap_get(struct rte_eth_dev *dev __rte_unused, struct rte_mtr_error *error __rte_unused) {struct rte_mtr_capabilities capa = { - .n_max =ZXDH_MAX_MTR_NUM , - .n_shared_max =ZXDH_SHARE_FLOW_MAX , - .meter_srtcm_rfc2697_n_max =ZXDH_MAX_MTR_PROFILE_NUM , - .meter_trtcm_rfc2698_n_max =ZXDH_MAX_MTR_PROFILE_NUM , - .color_aware_srtcm_rfc2697_supported =1 , - .color_aware_trtcm_rfc2698_supported =1 , - .meter_rate_max =ZXDH_SRTCM_CIR_MAX_BPS , - .meter_policy_n_max =ZXDH_MAX_POLICY_NUM , - .srtcm_rfc2697_byte_mode_supported =1 , - .srtcm_rfc2697_packet_mode_supported =1 , - .trtcm_rfc2698_byte_mode_supported =1 , - .trtcm_rfc2698_packet_mode_supported =1 , - .stats_mask =RTE_MTR_STATS_N_PKTS_DROPPED |RTE_MTR_STATS_N_BYTES_DROPPED , + .n_max =ZXDH_MAX_MTR_NUM , + .n_shared_max =ZXDH_SHARE_FLOW_MAX , + .meter_srtcm_rfc2697_n_max =ZXDH_MAX_MTR_PROFILE_NUM , + .meter_trtcm_rfc2698_n_max =ZXDH_MAX_MTR_PROFILE_NUM , + .color_aware_srtcm_rfc2697_supported =1 , + .color_aware_trtcm_rfc2698_supported =1 , + .meter_rate_max =ZXDH_SRTCM_CIR_MAX_BPS , + .meter_policy_n_max =ZXDH_MAX_POLICY_NUM , + .srtcm_rfc2697_byte_mode_supported =1 , + .srtcm_rfc2697_packet_mode_supported =1 , + .trtcm_rfc2698_byte_mode_supported =1 , + .trtcm_rfc2698_packet_mode_supported =1 , + .stats_mask =RTE_MTR_STATS_N_PKTS_DROPPED |RTE_MTR_STATS_N_BYTES_DROPPED , }; -memcpy (cap, &capa,sizeof (capa)); + *cap = capa;return 0 ; }
Signature · 1 line
2.47.2