Re: [PATCH 01/15] net: hbl_cn: add habanalabs Core Network driver

From: Stephen Hemminger
Date: Fri Jun 14 2024 - 20:06:06 EST



> +#define HBL_AUX2NIC(aux_dev) \
> + ({ \
> + struct hbl_aux_dev *__aux_dev = (aux_dev); \
> + ((__aux_dev)->type == HBL_AUX_DEV_ETH) ? \
> + container_of(__aux_dev, struct hbl_cn_device, en_aux_dev) : \
> + container_of(__aux_dev, struct hbl_cn_device, ib_aux_dev); \
> + })
> +
> +#define RAND_STAT_CNT(cnt) \
> + do { \
> + u32 __cnt = get_random_u32(); \
> + (cnt) = __cnt; \
> + dev_info(hdev->dev, "port %d, %s: %u\n", port, #cnt, __cnt); \
> + } while (0)
> +
> +struct hbl_cn_stat hbl_cn_mac_fec_stats[] = {
> + {"correctable_errors", 0x2, 0x3},
> + {"uncorrectable_errors", 0x4, 0x5}
> +};
> +

These tables should be marked const?

> +struct hbl_cn_stat hbl_cn_mac_stats_rx[] = {
> + {"Octets", 0x0},
> + {"OctetsReceivedOK", 0x4},
> + {"aAlignmentErrors", 0x8},
> + {"aPAUSEMACCtrlFramesReceived", 0xC},
> + {"aFrameTooLongErrors", 0x10},
> + {"aInRangeLengthErrors", 0x14},
> + {"aFramesReceivedOK", 0x18},
> + {"aFrameCheckSequenceErrors", 0x1C},
> + {"VLANReceivedOK", 0x20},
> + {"ifInErrors", 0x24},
> + {"ifInUcastPkts", 0x28},
> + {"ifInMulticastPkts", 0x2C},
> + {"ifInBroadcastPkts", 0x30},
> + {"DropEvents", 0x34},
> + {"Pkts", 0x38},
> + {"UndersizePkts", 0x3C},
> + {"Pkts64Octets", 0x40},
> + {"Pkts65to127Octets", 0x44},
> + {"Pkts128to255Octets", 0x48},
> + {"Pkts256to511Octets", 0x4C},
> + {"Pkts512to1023Octets", 0x50},
> + {"Pkts1024to1518Octets", 0x54},
> + {"Pkts1519toMaxOctets", 0x58},
> + {"OversizePkts", 0x5C},
> + {"Jabbers", 0x60},
> + {"Fragments", 0x64},
> + {"aCBFCPAUSERx0", 0x68},
> + {"aCBFCPAUSERx1", 0x6C},
> + {"aCBFCPAUSERx2", 0x70},
> + {"aCBFCPAUSERx3", 0x74},
> + {"aCBFCPAUSERx4", 0x78},
> + {"aCBFCPAUSERx5", 0x7C},
> + {"aCBFCPAUSERx6", 0x80},
> + {"aCBFCPAUSERx7", 0x84},
> + {"aMACControlFramesReceived", 0x88}
> +};
> +
> +struct hbl_cn_stat hbl_cn_mac_stats_tx[] = {
> + {"Octets", 0x0},
> + {"OctetsTransmittedOK", 0x4},
> + {"aPAUSEMACCtrlFramesTransmitted", 0x8},
> + {"aFramesTransmittedOK", 0xC},
> + {"VLANTransmittedOK", 0x10},
> + {"ifOutErrors", 0x14},
> + {"ifOutUcastPkts", 0x18},
> + {"ifOutMulticastPkts", 0x1C},
> + {"ifOutBroadcastPkts", 0x20},
> + {"Pkts64Octets", 0x24},
> + {"Pkts65to127Octets", 0x28},
> + {"Pkts128to255Octets", 0x2C},
> + {"Pkts256to511Octets", 0x30},
> + {"Pkts512to1023Octets", 0x34},
> + {"Pkts1024to1518Octets", 0x38},
> + {"Pkts1519toMaxOctets", 0x3C},
> + {"aCBFCPAUSETx0", 0x40},
> + {"aCBFCPAUSETx1", 0x44},
> + {"aCBFCPAUSETx2", 0x48},
> + {"aCBFCPAUSETx3", 0x4C},
> + {"aCBFCPAUSETx4", 0x50},
> + {"aCBFCPAUSETx5", 0x54},
> + {"aCBFCPAUSETx6", 0x58},
> + {"aCBFCPAUSETx7", 0x5C},
> + {"aMACControlFramesTx", 0x60},
> + {"Pkts", 0x64}
> +};
> +
> +static const char pcs_counters_str[][ETH_GSTRING_LEN] = {
> + {"pcs_local_faults"},
> + {"pcs_remote_faults"},
> + {"pcs_remote_fault_reconfig"},
> + {"pcs_link_restores"},
> + {"pcs_link_toggles"},
> +};
> +
> +static size_t pcs_counters_str_len = ARRAY_SIZE(pcs_counters_str);
> +size_t hbl_cn_mac_fec_stats_len = ARRAY_SIZE(hbl_cn_mac_fec_stats);
> +size_t hbl_cn_mac_stats_rx_len = ARRAY_SIZE(hbl_cn_mac_stats_rx);
> +size_t hbl_cn_mac_stats_tx_len = ARRAY_SIZE(hbl_cn_mac_stats_tx);
> +
> +static void qps_stop(struct hbl_cn_device *hdev);
> +static void qp_destroy_work(struct work_struct *work);
> +static int __user_wq_arr_unset(struct hbl_cn_ctx *ctx, struct hbl_cn_port *cn_port, u32 type);
> +static void user_cq_destroy(struct kref *kref);
> +static void set_app_params_clear(struct hbl_cn_device *hdev);
> +static int hbl_cn_ib_cmd_ctrl(struct hbl_aux_dev *aux_dev, void *cn_ib_ctx, u32 op, void *input,
> + void *output);
> +static int hbl_cn_ib_query_mem_handle(struct hbl_aux_dev *ib_aux_dev, u64 mem_handle,
> + struct hbl_ib_mem_info *info);
> +
> +static void hbl_cn_reset_stats_counters_port(struct hbl_cn_device *hdev, u32 port);
> +static void hbl_cn_late_init(struct hbl_cn_device *hdev);
> +static void hbl_cn_late_fini(struct hbl_cn_device *hdev);
> +static int hbl_cn_sw_init(struct hbl_cn_device *hdev);
> +static void hbl_cn_sw_fini(struct hbl_cn_device *hdev);
> +static void hbl_cn_spmu_init(struct hbl_cn_port *cn_port, bool full);
> +static int hbl_cn_cmd_port_check(struct hbl_cn_device *hdev, u32 port, u32 flags);
> +static void hbl_cn_qps_stop(struct hbl_cn_port *cn_port);

Can you reorder code so forward declarations are not required?