diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-06-14 12:33:15 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-06-14 12:33:15 +0000 |
commit | 0646fbda486564f5c3308a3ae3c9aa6bc85ac9e5 (patch) | |
tree | 551f3a6ce79941b1a94bc1aad1b5678441a6ffd5 | |
parent | 8118caaf6ac0df6a54351bfd800aea92a6ac3cca (diff) | |
parent | 14b24e2b79293068c8e016a69ef1d872fb5e2fd5 (diff) | |
download | illumos-joyent-0646fbda486564f5c3308a3ae3c9aa6bc85ac9e5.tar.gz |
[illumos-gate merge]
commit 14b24e2b79293068c8e016a69ef1d872fb5e2fd5
9506 Want support for QLogic QL41000/45000 series devices
commit cfad065142375b14439598ab13b09a95be0ad333
9589 ldterm_dosig() can send empty mblks downstream
Conflicts:
usr/src/uts/intel/qede/Makefile
usr/src/uts/common/io/qede/qede_version.h
usr/src/uts/common/io/qede/qede_types.h
usr/src/uts/common/io/qede/qede_osal.c
usr/src/uts/common/io/qede/qede_main.c
usr/src/uts/common/io/qede/qede_list.h
usr/src/uts/common/io/qede/qede_kstat.c
usr/src/uts/common/io/qede/qede_gld.c
usr/src/uts/common/io/qede/qede_fp.h
usr/src/uts/common/io/qede/qede_fp.c
usr/src/uts/common/io/qede/qede_dbg.c
usr/src/uts/common/io/qede/qede_cfg.c
usr/src/uts/common/io/qede/qede.h
exception_lists/hdrchk
exception_lists/cstyle
-rw-r--r-- | usr/src/pkg/manifests/driver-network-qede.mf | 42 | ||||
-rw-r--r-- | usr/src/uts/common/Makefile.rules | 3 | ||||
-rw-r--r-- | usr/src/uts/common/io/ldterm.c | 6 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede.h | 195 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_cfg.c | 164 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_dbg.c | 100 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_fp.c | 427 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_fp.h | 22 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_gld.c | 1189 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_kstat.c | 1296 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_list.h | 47 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_main.c | 1159 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_osal.c | 264 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_types.h | 5 | ||||
-rw-r--r-- | usr/src/uts/common/io/qede/qede_version.h | 7 | ||||
-rw-r--r-- | usr/src/uts/intel/Makefile | 3 | ||||
-rw-r--r-- | usr/src/uts/intel/qede/Makefile | 13 |
17 files changed, 2748 insertions, 2194 deletions
diff --git a/usr/src/pkg/manifests/driver-network-qede.mf b/usr/src/pkg/manifests/driver-network-qede.mf new file mode 100644 index 0000000000..ed32e6b9f3 --- /dev/null +++ b/usr/src/pkg/manifests/driver-network-qede.mf @@ -0,0 +1,42 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2018 Joyent, Inc. +# + +<include global_zone_only_component> +set name=pkg.fmri value=pkg:/driver/network/qede@$(PKGVERS) +set name=pkg.description value="QLogic FastLinQ QL45xxx Ethernet Driver" +set name=pkg.summary value="QLogic FastLinQ QL45xxx Ethernet Driver" +set name=info.classification \ + value=org.opensolaris.category.2008:Drivers/Networking +set name=variant.arch value=i386 +dir path=kernel group=sys +dir path=kernel/drv group=sys +dir path=kernel/drv/$(ARCH64) group=sys +dir path=usr/share/man +dir path=usr/share/man/man7d +driver name=qede clone_perms="qede 0666 root sys" perms="* 0666 root sys" \ + alias=pciex1077,1629 \ + alias=pciex1077,1630 \ + alias=pciex1077,1634 \ + alias=pciex1077,1654 \ + alias=pciex1077,1656 \ + alias=pciex1077,1666 \ + alias=pciex1077,8070 \ + alias=pciex1077,8071 \ + alias=pciex1077,8072 \ + alias=pciex1077,8073 +file path=kernel/drv/$(ARCH64)/qede group=sys +file path=kernel/drv/qede.conf group=sys +file path=usr/share/man/man7d/qede.7d +license lic_CDDL license=lic_CDDL diff --git a/usr/src/uts/common/Makefile.rules b/usr/src/uts/common/Makefile.rules index 95bb020a63..7c9834f3d3 100644 --- a/usr/src/uts/common/Makefile.rules +++ b/usr/src/uts/common/Makefile.rules @@ -2423,6 +2423,9 @@ $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/ppp/spppasyn/%.c $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/ppp/sppptun/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/qede/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) + $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/ral/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/common/io/ldterm.c b/usr/src/uts/common/io/ldterm.c index 1af97c86ea..ff36dab948 100644 --- a/usr/src/uts/common/io/ldterm.c +++ b/usr/src/uts/common/io/ldterm.c @@ -4069,8 +4069,10 @@ ldterm_dosig(queue_t *q, int sig, uchar_t c, int mtype, int mode) if (c != '\0') { if ((tp->t_echomp = allocb(4, BPRI_HI)) != NULL) { - (void) ldterm_echo(c, WR(q), 4, tp); - putnext(WR(q), tp->t_echomp); + if (ldterm_echo(c, WR(q), 4, tp) > 0) + putnext(WR(q), tp->t_echomp); + else + freemsg(tp->t_echomp); tp->t_echomp = NULL; } } diff --git a/usr/src/uts/common/io/qede/qede.h b/usr/src/uts/common/io/qede/qede.h index 0f0496a205..3fe3da4ec2 100644 --- a/usr/src/uts/common/io/qede/qede.h +++ b/usr/src/uts/common/io/qede/qede.h @@ -106,8 +106,9 @@ #endif #define QEDE_STR_SIZE 32 /* Product Identification Banner */ -//#define QEDE_PRODUCT_INFO "QLogic 40/100G NIC v" STRINGIFY(MAJVERSION) "." STRINGIFY(MINVERSION) "." STRINGIFY(REVVERSION) -#define QEDE_PRODUCT_INFO "QLogic FastLinQ QL45xxx " STRINGIFY(MAJVERSION) "." STRINGIFY(MINVERSION) "." STRINGIFY(REVVERSION) +#define QEDE_PRODUCT_INFO\ + "QLogic FastLinQ QL45xxx " STRINGIFY(MAJVERSION) \ + "." STRINGIFY(MINVERSION) "." STRINGIFY(REVVERSION) /* * Debug Infrastructure @@ -122,21 +123,22 @@ #define qede_dbg(MASK, ptr, fmt, ...) \ do { \ if (DEBUG_LEVEL & (MASK)) { \ - qede_print("!%s(%d) STRINGIFY(MASK):" fmt, __func__, (ptr)->instance, \ - ##__VA_ARGS__);\ + qede_print("!%s(%d) STRINGIFY(MASK):" fmt, __func__, \ + (ptr)->instance, \ +##__VA_ARGS__);\ } \ } while (0); #define qede_info(ptr, fmt, ...) \ do { \ qede_print("!%s(%d):" fmt, __func__, (ptr)->instance, \ - ##__VA_ARGS__); \ +##__VA_ARGS__); \ } while (0); #define qede_warn(ptr, fmt, ...) \ do { \ qede_print_err("!%s(%d):" fmt, __func__, (ptr)->instance, \ - ##__VA_ARGS__); \ +##__VA_ARGS__); \ } while (0); #ifdef __sparc @@ -158,8 +160,8 @@ do { \ #define QEDE_LSO_MAXLEN 65535 -#define BUF_2K_SIZE 2048 -#define BUF_2K_ALIGNMENT BUF_2K_SIZE +#define BUF_2K_SIZE 2048 +#define BUF_2K_ALIGNMENT BUF_2K_SIZE #define MIN_TX_RING_COUNT 1 #define MAX_TX_RING_COUNT 1 @@ -173,7 +175,7 @@ do { \ #define DEFAULT_TX_COPY_THRESHOLD 256 #define DEFAULT_TX_RECYCLE_THRESHOLD 128 -#define TX_RING_MASK (tx_ring->tx_ring_size - 1) +#define TX_RING_MASK (tx_ring->tx_ring_size - 1) #define IP_ALIGNMENT_BYTES 2 #define QEDE_MAX_ETHER_HDR 18 @@ -191,7 +193,7 @@ do { \ #define DEFAULT_RX_BUF_SIZE 2048 #define DEFAULT_RX_COPY_THRESHOLD 128 -#define RX_RING_MASK (rx_ring->rx_buf_count - 1) +#define RX_RING_MASK (rx_ring->rx_buf_count - 1) #define MIN_RX_BUF_COUNT MIN_RX_RING_SIZE #define MAX_RX_BUF_COUNT MAX_RX_RING_SIZE #define DEFAULT_RX_BUF_COUNT DEFAULT_RX_RING_SIZE @@ -241,39 +243,39 @@ do { \ typedef struct _KstatRingMap { - uint32_t idx; /* ring index */ - void * qede; /* reference back to qede_t */ + uint32_t idx; /* ring index */ + void * qede; /* reference back to qede_t */ } KstatRingMap; -#define IS_ETH_MULTICAST(eth_addr) \ +#define IS_ETH_MULTICAST(eth_addr) \ (((unsigned char *) (eth_addr))[0] & ((unsigned char) 0x01)) -#define IS_ETH_ADDRESS_EQUAL(eth_addr1, eth_addr2) \ - ((((unsigned char *) (eth_addr1))[0] == \ - ((unsigned char *) (eth_addr2))[0]) && \ - (((unsigned char *) (eth_addr1))[1] == \ - ((unsigned char *) (eth_addr2))[1]) && \ - (((unsigned char *) (eth_addr1))[2] == \ - ((unsigned char *) (eth_addr2))[2]) && \ - (((unsigned char *) (eth_addr1))[3] == \ - ((unsigned char *) (eth_addr2))[3]) && \ - (((unsigned char *) (eth_addr1))[4] == \ - ((unsigned char *) (eth_addr2))[4]) && \ - (((unsigned char *) (eth_addr1))[5] == \ +#define IS_ETH_ADDRESS_EQUAL(eth_addr1, eth_addr2) \ + ((((unsigned char *) (eth_addr1))[0] == \ + ((unsigned char *) (eth_addr2))[0]) && \ + (((unsigned char *) (eth_addr1))[1] == \ + ((unsigned char *) (eth_addr2))[1]) && \ + (((unsigned char *) (eth_addr1))[2] == \ + ((unsigned char *) (eth_addr2))[2]) && \ + (((unsigned char *) (eth_addr1))[3] == \ + ((unsigned char *) (eth_addr2))[3]) && \ + (((unsigned char *) (eth_addr1))[4] == \ + ((unsigned char *) (eth_addr2))[4]) && \ + (((unsigned char *) (eth_addr1))[5] == \ ((unsigned char *) (eth_addr2))[5])) -#define COPY_ETH_ADDRESS(src, dst) \ - ((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ - ((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ - ((unsigned char *) (dst))[2] = ((unsigned char *) (src))[2]; \ - ((unsigned char *) (dst))[3] = ((unsigned char *) (src))[3]; \ - ((unsigned char *) (dst))[4] = ((unsigned char *) (src))[4]; \ +#define COPY_ETH_ADDRESS(src, dst) \ + ((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ + ((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ + ((unsigned char *) (dst))[2] = ((unsigned char *) (src))[2]; \ + ((unsigned char *) (dst))[3] = ((unsigned char *) (src))[3]; \ + ((unsigned char *) (dst))[4] = ((unsigned char *) (src))[4]; \ ((unsigned char *) (dst))[5] = ((unsigned char *) (src))[5]; union db_prod { struct eth_db_data data; - uint32_t raw; + uint32_t raw; }; struct qede; @@ -283,9 +285,9 @@ struct qede_tx_pktinfo_s; typedef struct qede_tx_ring { struct qede_fastpath *fp; - struct qede *qede; - uint32_t tx_queue_index; - uint16_t *hw_cons_ptr; + struct qede *qede; + uint32_t tx_queue_index; + uint16_t *hw_cons_ptr; /* pointer to driver ring control */ struct ecore_chain tx_bd_ring; @@ -294,7 +296,7 @@ typedef struct qede_tx_ring { u16 bd_ring_size; /* From ecore_sp_tx_queue_start() */ - void __iomem *doorbell_addr; + void __iomem *doorbell_addr; ddi_acc_handle_t doorbell_handle; /* Saved copy of doorbell data for this tx queue */ @@ -312,7 +314,7 @@ typedef struct qede_tx_ring { /* pre-allocated dma handles */ qede_dma_handles_list_t dmah_list; /* List of recycle entires for tx packets */ - qede_tx_recycle_list_t *tx_recycle_list; + qede_tx_recycle_list_t *tx_recycle_list; #ifdef DBLK_DMA_PREMAP pm_handle_t pm_handle; @@ -323,21 +325,21 @@ typedef struct qede_tx_ring { bool tx_q_sleeping; - uint64_t tx_pkt_count; - uint64_t tx_byte_count; - uint64_t tx_pkt_dropped; - uint64_t tx_copy_count; - uint64_t tx_bind_count; - uint64_t tx_bind_fail; - uint64_t tx_premap_count; - uint64_t tx_premap_fail; - uint64_t tx_pullup_count; - uint64_t tx_too_many_cookies; - uint64_t tx_lso_pkt_count; - uint64_t tx_ring_pause; - uint64_t tx_too_many_mblks; - uint64_t tx_mapped_pkts; - uint64_t tx_jumbo_pkt_count; + uint64_t tx_pkt_count; + uint64_t tx_byte_count; + uint64_t tx_pkt_dropped; + uint64_t tx_copy_count; + uint64_t tx_bind_count; + uint64_t tx_bind_fail; + uint64_t tx_premap_count; + uint64_t tx_premap_fail; + uint64_t tx_pullup_count; + uint64_t tx_too_many_cookies; + uint64_t tx_lso_pkt_count; + uint64_t tx_ring_pause; + uint64_t tx_too_many_mblks; + uint64_t tx_mapped_pkts; + uint64_t tx_jumbo_pkt_count; struct ecore_queue_cid *p_cid; } qede_tx_ring_t; @@ -348,7 +350,7 @@ typedef struct qede_vector_info { * or to a hwfnc. */ void *fp; - struct qede *qede; + struct qede *qede; uint32_t vect_index; bool handler_added; /* set and cleared by ISR, checked by stop path @@ -359,18 +361,18 @@ typedef struct qede_vector_info { typedef struct qede_fastpath { - qede_vector_info_t *vect_info; + qede_vector_info_t *vect_info; /* Status block associated with this fp */ ddi_dma_handle_t sb_dma_handle; ddi_acc_handle_t sb_acc_handle; - struct status_block *sb_virt; + struct status_block *sb_virt; uint64_t sb_phys; - struct ecore_sb_info *sb_info; - struct qede_rx_ring *rx_ring; - qede_tx_ring_t *tx_ring[MAX_TC]; - struct qede *qede; + struct ecore_sb_info *sb_info; + struct qede_rx_ring *rx_ring; + qede_tx_ring_t *tx_ring[MAX_TC]; + struct qede *qede; uint32_t fp_index; uint32_t fp_hw_eng_index; @@ -379,7 +381,7 @@ typedef struct qede_fastpath { uint32_t rx_queue_index; uint32_t rss_id; kmutex_t fp_lock; - uint32_t disabled_by_poll; + uint32_t disabled_by_poll; } qede_fastpath_t; enum qede_agg_state { @@ -408,7 +410,7 @@ typedef struct qede_dma_info_s { u32 ncookies; u32 offset; u64 phys_addr; - void *virt_addr; + void *virt_addr; u32 pad; } qede_dma_info_t; @@ -423,9 +425,9 @@ struct qede_rx_buf_area; typedef struct qede_rx_buffer_s { qede_dma_info_t dma_info; - mblk_t *mp; + mblk_t *mp; u32 index; - struct qede_rx_ring *rx_ring; + struct qede_rx_ring *rx_ring; /* Recycle function */ frtn_t recycle; @@ -438,7 +440,7 @@ typedef struct qede_rx_buf_list_s { kmutex_t lock; u16 head, tail; u32 num_entries; - qede_rx_buffer_t *buf_list[DEFAULT_RX_RING_SIZE]; + qede_rx_buffer_t *buf_list[DEFAULT_RX_RING_SIZE]; } qede_rx_buf_list_t; typedef struct qede_rx_buf_area { @@ -449,7 +451,7 @@ typedef struct qede_rx_buf_area { qede_rx_buf_list_t passive_buf_list; u32 bufs_per_page; - struct qede_rx_ring *rx_ring; + struct qede_rx_ring *rx_ring; u32 inactive; u32 buf_upstream; } qede_rx_buf_area_t; @@ -464,7 +466,7 @@ typedef struct qede_rx_ring { * to update producer indicies for * CQE and RX buffer chains. */ - void __iomem *hw_rxq_prod_addr; + void __iomem *hw_rxq_prod_addr; /* Pointer to hw cqe consumer index. * Taken from sb_virt->pi_array after @@ -475,7 +477,7 @@ typedef struct qede_rx_ring { * It is updated by ecore and read by * the driver while processing rings. */ - uint16_t *hw_cons_ptr; + uint16_t *hw_cons_ptr; u16 sw_rx_cons; u16 sw_rx_prod; @@ -486,8 +488,8 @@ typedef struct qede_rx_ring { * buffers on a one-to-one releationship * to ecore_chain rx_bd_ring. */ - qede_rx_buffer_t *rx_buffers; - qede_rx_buf_area_t *rx_buf_area; + qede_rx_buffer_t *rx_buffers; + qede_rx_buf_area_t *rx_buf_area; /* * Descriptor rings returned from * ecore_chain_alloc() @@ -504,7 +506,7 @@ typedef struct qede_rx_ring { u64 mr_gen_num; /* Mac rings generation number */ uint32_t group_index; qede_fastpath_t *fp; - struct qede *qede; + struct qede *qede; /* dma_handles for rx dma mem */ ddi_dma_handle_t rx_bd_dmah; @@ -611,7 +613,6 @@ enum qede_filter_rx_mode_type { }; -/*VAI*/ struct qede_mcast_filter_params { enum qede_filter_rx_mode_type acc_flg; @@ -677,7 +678,7 @@ enum qede_vport_state { typedef struct qede_mac_group { int group_index; mac_group_handle_t group_handle; - struct qede *qede; + struct qede *qede; } qede_mac_group_t; typedef struct qede_link_input_params { @@ -687,7 +688,7 @@ typedef struct qede_link_input_params { typedef struct qede { struct ecore_dev edev; /* keep this at the beginning of the structure */ - dev_info_t *dip; + dev_info_t *dip; int instance; enum qede_state qede_state; #define MAX_QEDE_NAME_LEN 8 @@ -718,7 +719,7 @@ typedef struct qede { qede_mac_group_t rx_groups[QEDE_MAX_GROUPS]; qede_mac_group_t tx_groups[QEDE_MAX_GROUPS]; - u8 *sp_dpc; + u8 *sp_dpc; /* * pre-mapped buffer cache handle for TX * used for getting sglist for mbkls @@ -771,7 +772,7 @@ typedef struct qede { qede_fastpath_t fp_array[MAX_FASTPATH_COUNT]; struct ecore_sb_info sb_array[MAX_FASTPATH_COUNT]; qede_rx_ring_t rx_array[MAX_FASTPATH_COUNT]; - qede_tx_ring_t tx_array[MAX_TC_COUNT][MAX_FASTPATH_COUNT]; + qede_tx_ring_t tx_array[MAX_TC_COUNT][MAX_FASTPATH_COUNT]; uint16_t tx_bcopy_threshold; uint16_t pad1; /* remove later */ @@ -819,40 +820,37 @@ typedef struct qede { uint64_t intrFired; kmutex_t kstat_lock; kmutex_t gld_lock; - uint64_t intrSbCnt[MAX_FASTPATH_COUNT + 1]; /* TBD */ - uint64_t intrSbNoChangeCnt[MAX_FASTPATH_COUNT + 1]; + uint64_t intrSbCnt[MAX_FASTPATH_COUNT + 1]; + uint64_t intrSbNoChangeCnt[MAX_FASTPATH_COUNT + 1]; uint64_t intrSbPollCnt[MAX_FASTPATH_COUNT + 1]; uint64_t intrSbPollNoChangeCnt[MAX_FASTPATH_COUNT + 1]; - ddi_dma_handle_t sp_sb_handle; - ddi_dma_handle_t sp_attn_handle; - timeout_id_t qede_watchdog_tid; - boolean_t qede_watchdog_enable; - boolean_t qede_watchdog_start; - kmutex_t qede_watchdog_lock; - uint32_t qede_watchdog_flow_control; - kstat_t * kstats; - kstat_t * kstats_link; - kstat_t * kstats_intr; - kstat_t * kstats_vport; - kstat_t * kstats_rxq[MAX_FASTPATH_COUNT]; + kstat_t *kstats; + kstat_t *kstats_link; + kstat_t *kstats_intr; + kstat_t *kstats_vport; + kstat_t *kstats_rxq[MAX_FASTPATH_COUNT]; KstatRingMap kstats_rxq_map[MAX_FASTPATH_COUNT]; - kstat_t * kstats_txq[MAX_FASTPATH_COUNT]; + kstat_t *kstats_txq[MAX_FASTPATH_COUNT]; KstatRingMap kstats_txq_map[MAX_FASTPATH_COUNT]; struct ecore_eth_stats save_stats; - mblk_t *stored_mp; + mblk_t *stored_mp; int mp_index; qede_link_input_params_t link_input_params; /*(test) */ uint32_t loop_back_mode; /*(test) */ bool lb_linkup; /*(test) */ uint32_t forced_speed_10G; - uint8_t pci_func; /*added for func_info ioctl*/ - void *nvm_buf; - void *nvm_buf_start; + uint8_t pci_func; + void *nvm_buf; + void *nvm_buf_start; uint32_t nvm_buf_size; uint32_t copy_len; uint8_t *reserved_buf; + int fm_cap; + uint64_t allocbFailures; + volatile uint32_t detach_unsafe; + } qede_t; /* @@ -1010,14 +1008,15 @@ enum { extern qede_link_props_t qede_def_link_props; /* Functions exported by qede_cfg.c */ -void qede_cfg_reset(qede_t * qede); +void qede_cfg_reset(qede_t *qede); void qede_cfg_init(qede_t *qede); /* Functions exported by qede_gld.c */ -boolean_t qede_gld_init(qede_t * qede); +boolean_t qede_gld_init(qede_t *qede); int qede_multicast(qede_t * qede, boolean_t flag, const uint8_t *ptr_mcaddr); -int qede_set_filter_rx_mode(qede_t * qede, enum qede_filter_rx_mode_type type); -int qede_set_rx_mac_mcast(qede_t *qede, enum ecore_filter_opcode opcode,uint8_t *mac, int mc_cnt); +int qede_set_filter_rx_mode(qede_t *qede, enum qede_filter_rx_mode_type type); +int qede_set_rx_mac_mcast(qede_t *qede, enum ecore_filter_opcode opcode, + uint8_t *mac, int mc_cnt); int qede_ucst_find(qede_t *qede, const uint8_t *mac_addr); int qede_clear_filters(qede_t *qede); /* Functions exported by qede_main.c */ diff --git a/usr/src/uts/common/io/qede/qede_cfg.c b/usr/src/uts/common/io/qede/qede_cfg.c index d597136b61..1b52c27d93 100644 --- a/usr/src/uts/common/io/qede/qede_cfg.c +++ b/usr/src/uts/common/io/qede/qede_cfg.c @@ -36,26 +36,29 @@ #include "qede.h" -qede_link_props_t qede_def_link_props = { -GLDM_FIBER, -B_TRUE, -B_TRUE, -B_TRUE, -B_TRUE, -B_TRUE, -B_TRUE, -B_TRUE, -B_TRUE, -B_FALSE +qede_link_props_t qede_def_link_props = +{ + GLDM_FIBER, + B_TRUE, + B_TRUE, + B_TRUE, + B_TRUE, + B_TRUE, + B_TRUE, + B_TRUE, + B_TRUE, + B_FALSE }; -static void qede_cfg_get_val(qede_t * qede, - char * pName, - void * pVal, - int defaultVal, - boolean_t boolVal) +static void +qede_cfg_get_val(qede_t *qede, + char * pName, + void * pVal, + int defaultVal, + boolean_t boolVal) { int val; -#define QEDE_CFG_NAME_LEN_MAX 128 +#define QEDE_CFG_NAME_LEN_MAX 128 + char name[QEDE_CFG_NAME_LEN_MAX]; /* first check if the hardcoded default has been overridden */ @@ -63,31 +66,30 @@ static void qede_cfg_get_val(qede_t * qede, snprintf(name, QEDE_CFG_NAME_LEN_MAX, "default_%s", pName); val = ddi_prop_get_int(DDI_DEV_T_ANY, - qede->dip, - (DDI_PROP_NOTPROM | DDI_PROP_DONTPASS), - name, - defaultVal); + qede->dip, + (DDI_PROP_NOTPROM | DDI_PROP_DONTPASS), + name, + defaultVal); /* now check for a config for this specific instance */ - snprintf(name, QEDE_CFG_NAME_LEN_MAX, "qede%d_%s", qede->instance, pName); + snprintf(name, QEDE_CFG_NAME_LEN_MAX, "qede%d_%s", qede->instance, + pName); val = ddi_prop_get_int(DDI_DEV_T_ANY, - qede->dip, - (DDI_PROP_NOTPROM | DDI_PROP_DONTPASS), - name, - val); + qede->dip, + (DDI_PROP_NOTPROM | DDI_PROP_DONTPASS), + name, + val); - if (boolVal) - { + if (boolVal) { *((boolean_t *)pVal) = (val) ? B_TRUE : B_FALSE; - } - else - { + } else { *((int *)pVal) = val; } } -void qede_cfg_init(qede_t *qede) +void +qede_cfg_init(qede_t *qede) { int option; @@ -111,74 +113,75 @@ void qede_cfg_init(qede_t *qede) &qede->checksum, qede->checksum, B_FALSE); - switch(qede->checksum) - { - case USER_OPTION_CKSUM_L3: - case USER_OPTION_CKSUM_L3_L4: - qede->checksum = DEFAULT_CKSUM_OFFLOAD; - break; + switch(qede->checksum) { + case USER_OPTION_CKSUM_L3: + case USER_OPTION_CKSUM_L3_L4: + qede->checksum = DEFAULT_CKSUM_OFFLOAD; + break; } qede_cfg_get_val(qede, "mtu", &option, - qede->mtu, - B_FALSE); + qede->mtu, + B_FALSE); if (option != DEFAULT_JUMBO_MTU && option != DEFAULT_MTU) { qede->mtu = DEFAULT_MTU; qede->jumbo_enable = B_FALSE; } else { - if (qede->mtu != option) + if (qede->mtu != option) { qede->mtu = option; - if (option == DEFAULT_JUMBO_MTU) + } + if (option == DEFAULT_JUMBO_MTU) { qede->jumbo_enable = B_TRUE; + } } qede_cfg_get_val(qede, "num_fp", &option, - qede->num_fp, - B_FALSE); + qede->num_fp, + B_FALSE); qede->num_fp = (option < MIN_FASTPATH_COUNT) ? - MIN_FASTPATH_COUNT : - (option > MAX_FASTPATH_COUNT) ? - MAX_FASTPATH_COUNT : - option; + MIN_FASTPATH_COUNT : + (option > MAX_FASTPATH_COUNT) ? + MAX_FASTPATH_COUNT : + option; qede_cfg_get_val(qede, "rx_ring_size", &option, - qede->rx_ring_size, - B_FALSE); + qede->rx_ring_size, + B_FALSE); qede->rx_ring_size = (option < MIN_RX_RING_SIZE) ? - MIN_RX_RING_SIZE : - (option > MAX_RX_RING_SIZE) ? - MAX_RX_RING_SIZE : - option; + MIN_RX_RING_SIZE : + (option > MAX_RX_RING_SIZE) ? + MAX_RX_RING_SIZE : + option; qede_cfg_get_val(qede, "tx_ring_size", &option, - qede->tx_ring_size, - B_FALSE); + qede->tx_ring_size, + B_FALSE); qede->tx_ring_size = (option < MIN_TX_RING_SIZE) ? - MIN_TX_RING_SIZE : - (option > MAX_TX_RING_SIZE) ? - MAX_TX_RING_SIZE : - option; + MIN_TX_RING_SIZE : + (option > MAX_TX_RING_SIZE) ? + MAX_TX_RING_SIZE : + option; qede_cfg_get_val(qede, "rx_copy_threshold", &option, - qede->rx_copy_threshold, - B_FALSE); + qede->rx_copy_threshold, + B_FALSE); qede_cfg_get_val(qede, "tx_copy_threshold", &option, - qede->tx_bcopy_threshold, - B_FALSE); + qede->tx_bcopy_threshold, + B_FALSE); qede_cfg_get_val(qede, "tx_recycle_threshold", &option, - qede->tx_bcopy_threshold, - B_FALSE); + qede->tx_bcopy_threshold, + B_FALSE); qede->tx_recycle_threshold = - (option < 0) ? 0: - (option > qede->tx_ring_size) ? - qede->tx_ring_size : option; + (option < 0) ? 0: + (option > qede->tx_ring_size) ? + qede->tx_ring_size : option; qede_cfg_get_val(qede, "lso_enable", &option, - qede->lso_enable, - B_TRUE); + qede->lso_enable, + B_TRUE); qede->lso_enable = option; qede_cfg_get_val(qede, "lro_enable", &option, - qede->lro_enable, - B_TRUE); + qede->lro_enable, + B_TRUE); qede->lro_enable = option; if(qede->checksum != DEFAULT_CKSUM_OFFLOAD) { @@ -187,21 +190,22 @@ void qede_cfg_init(qede_t *qede) } qede_cfg_get_val(qede, "log_enable", &option, - qede->log_enable, - B_TRUE); + qede->log_enable, + B_TRUE); qede_cfg_get_val(qede, "debug_level", &option, - qede->ecore_debug_level, - B_FALSE); + qede->ecore_debug_level, + B_FALSE); qede->ecore_debug_level = (uint32_t)((option < 0) ? 0 : option); qede_cfg_get_val(qede, "debug_module", &option, - qede->ecore_debug_module, - B_FALSE); + qede->ecore_debug_module, + B_FALSE); qede->ecore_debug_module = (uint32_t)((option < 0) ? 0 : option); } -void qede_cfg_reset(qede_t *qede) +void +qede_cfg_reset(qede_t *qede) { qede->params.link_state = 0; /* reset the link status */ diff --git a/usr/src/uts/common/io/qede/qede_dbg.c b/usr/src/uts/common/io/qede/qede_dbg.c index 39abdd5214..9a6f22fcd4 100644 --- a/usr/src/uts/common/io/qede/qede_dbg.c +++ b/usr/src/uts/common/io/qede/qede_dbg.c @@ -42,10 +42,10 @@ void qede_stacktrace(qede_t *qede) { - int depth, i; - pc_t pcstack[16]; - char *sym; - ulong_t off; + int depth, i; + pc_t pcstack[16]; + char *sym; + ulong_t off; depth = getpcstack(&pcstack[0], 16); @@ -67,7 +67,8 @@ qede_stacktrace(qede_t *qede) void qede_dbg_ipv6_ext_hdr(qede_tx_pktinfo_t *pktinfo, mblk_t *mp) { - struct ether_header *eth_hdr = (struct ether_header *)(void *)mp->b_rptr; + struct ether_header *eth_hdr = + (struct ether_header *)(void *)mp->b_rptr; ipha_t *ip_hdr; struct ip6_hdr *ipv6hdr = NULL; @@ -94,28 +95,32 @@ qede_dbg_ipv6_ext_hdr(qede_tx_pktinfo_t *pktinfo, mblk_t *mp) } } -char *qede_get_L4_type(uint16_t parse_flags) +char * +qede_get_L4_type(uint16_t parse_flags) { parse_flags = (parse_flags >> PARSING_AND_ERR_FLAGS_L4PROTOCOL_SHIFT) - & PARSING_AND_ERR_FLAGS_L4PROTOCOL_MASK; - if (parse_flags == 1) + & PARSING_AND_ERR_FLAGS_L4PROTOCOL_MASK; + if (parse_flags == 1) { return ("TCP"); - else if (parse_flags == 2) + } else if (parse_flags == 2) { return ("UDP"); - else + } else { return ("UNKNOWN"); + } } -char *qede_get_L3_type(uint16_t parse_flags) +char * +qede_get_L3_type(uint16_t parse_flags) { parse_flags = (parse_flags >> PARSING_AND_ERR_FLAGS_L3TYPE_SHIFT) - & PARSING_AND_ERR_FLAGS_L3TYPE_MASK; - if (parse_flags == 1) + & PARSING_AND_ERR_FLAGS_L3TYPE_MASK; + if (parse_flags == 1) { return ("IPv4"); - else if (parse_flags == 2) + } else if (parse_flags == 2) { return ("IPv6"); - else + } else { return ("UNKNOWN"); + } } @@ -177,7 +182,8 @@ qede_dump_bytes(char *buf, int len) { int i; for (i = 0; i < len; i += 8, buf+=8) { - cmn_err(CE_NOTE, "!%.02x %.02x %.02x %.02x %.02x %.02x %.02x %.02x", + cmn_err(CE_NOTE, + "!%.02x %.02x %.02x %.02x %.02x %.02x %.02x %.02x", buf[i + 0] & 0xff, buf[i + 1] & 0xff, buf[i + 2] & 0xff, buf[i + 3] & 0xff, buf[i + 4] & 0xff, buf[i + 5] & 0xff, @@ -246,61 +252,63 @@ qede_dump_mblk_chain_bnext_ptr(qede_t *qede, mblk_t *mp) void qede_print_intr_ctx(qede_intr_context_t *intr_ctx) { - return; } void qede_print_tx_ring(qede_tx_ring_t *tx_ring) { - return; } void qede_print_rx_ring(qede_rx_ring_t *rx_ring) { - return; } void qede_print_fastpath(qede_fastpath_t *fp) { - return; } void qede_print_qede(qede_t *qede) { - return; } /* * This function is called from ecore in the init path * just before starting the function */ -void qede_debug_before_pf_start(struct ecore_dev *edev, u8 id) +void +qede_debug_before_pf_start(struct ecore_dev *edev, u8 id) { } -void qede_debug_after_pf_stop(void *cdev, u8 my_id) +void +qede_debug_after_pf_stop(void *cdev, u8 my_id) { } -void qede_dump_reg_cqe(struct eth_fast_path_rx_reg_cqe *cqe) +void +qede_dump_reg_cqe(struct eth_fast_path_rx_reg_cqe *cqe) { cmn_err(CE_WARN, "qede_dump_reg_cqe"); cmn_err(CE_WARN, " pkt_len = %d", LE_16(cqe->pkt_len)); cmn_err(CE_WARN, " bd_num = %d", cqe->bd_num); - cmn_err(CE_WARN, " len_on_first_bd = %d", LE_16(cqe->len_on_first_bd)); + cmn_err(CE_WARN, " len_on_first_bd = %d", + LE_16(cqe->len_on_first_bd)); cmn_err(CE_WARN, " placement_offset = %d", cqe->placement_offset); cmn_err(CE_WARN, " vlan_tag = %d", LE_16(cqe->vlan_tag)); cmn_err(CE_WARN, " rss_hash = %d", LE_32(cqe->rss_hash)); - cmn_err(CE_WARN, " pars_flags = %x", LE_16((uint16_t)cqe->pars_flags.flags)); - cmn_err(CE_WARN, " tunnel_pars_flags = %x", cqe->tunnel_pars_flags.flags); + cmn_err(CE_WARN, " pars_flags = %x", + LE_16((uint16_t)cqe->pars_flags.flags)); + cmn_err(CE_WARN, " tunnel_pars_flags = %x", + cqe->tunnel_pars_flags.flags); cmn_err(CE_WARN, " bitfields = %x", cqe->bitfields); } -void qede_dump_start_lro_cqe(struct eth_fast_path_rx_tpa_start_cqe *cqe) +void +qede_dump_start_lro_cqe(struct eth_fast_path_rx_tpa_start_cqe *cqe) { int i; cmn_err(CE_WARN, "qede_dump_start_lro_cqe"); @@ -308,34 +316,46 @@ void qede_dump_start_lro_cqe(struct eth_fast_path_rx_tpa_start_cqe *cqe) cmn_err(CE_WARN, " seg_len = %d", LE_16(cqe->seg_len)); cmn_err(CE_WARN, " vlan_tag = %d", LE_16(cqe->vlan_tag)); cmn_err(CE_WARN, " rss_hash = %d", LE_32(cqe->rss_hash)); - cmn_err(CE_WARN, " len_on_first_bd = %d", LE_16(cqe->len_on_first_bd)); + cmn_err(CE_WARN, " len_on_first_bd = %d", + LE_16(cqe->len_on_first_bd)); cmn_err(CE_WARN, " placement_offset = %d", cqe->placement_offset); cmn_err(CE_WARN, " header_len = %d", cqe->header_len); for (i = 0; i < ETH_TPA_CQE_START_LEN_LIST_SIZE; i++) - cmn_err(CE_WARN, " ext_bd_len_list[%d] = %d", i, LE_16(cqe->ext_bd_len_list[i])); - cmn_err(CE_WARN, " pars_flags = 0x%x", LE_16((uint16_t)cqe->pars_flags.flags)); - cmn_err(CE_WARN, " tunnel_pars_flags = 0x%x", cqe->tunnel_pars_flags.flags); + cmn_err(CE_WARN, " ext_bd_len_list[%d] = %d", i, + LE_16(cqe->ext_bd_len_list[i])); + cmn_err(CE_WARN, " pars_flags = 0x%x", + LE_16((uint16_t)cqe->pars_flags.flags)); + cmn_err(CE_WARN, " tunnel_pars_flags = 0x%x", + cqe->tunnel_pars_flags.flags); cmn_err(CE_WARN, " bitfields = 0x%x", cqe->bitfields ); } -void qede_dump_cont_lro_cqe(struct eth_fast_path_rx_tpa_cont_cqe *cqe) +void +qede_dump_cont_lro_cqe(struct eth_fast_path_rx_tpa_cont_cqe *cqe) { int i; cmn_err(CE_WARN, "qede_dump_cont_lro_cqe"); cmn_err(CE_WARN, " tpa_agg_index = %d", cqe->tpa_agg_index); - for (i = 0; i < ETH_TPA_CQE_CONT_LEN_LIST_SIZE; i++) - cmn_err(CE_WARN, " len_list[%d] = %d", i, LE_16(cqe->len_list[i])); + for (i = 0; i < ETH_TPA_CQE_CONT_LEN_LIST_SIZE; i++) { + cmn_err(CE_WARN, " len_list[%d] = %d", i, + LE_16(cqe->len_list[i])); + } } -void qede_dump_end_lro_cqe(struct eth_fast_path_rx_tpa_end_cqe *cqe) +void +qede_dump_end_lro_cqe(struct eth_fast_path_rx_tpa_end_cqe *cqe) { int i; cmn_err(CE_WARN, "qede_dump_end_lro_cqe"); cmn_err(CE_WARN, " tpa_agg_index = %d", cqe->tpa_agg_index ); - cmn_err(CE_WARN, " total_packet_len = %d", LE_16(cqe->total_packet_len)); + cmn_err(CE_WARN, " total_packet_len = %d", + LE_16(cqe->total_packet_len)); cmn_err(CE_WARN, " num_of_bds = %d", cqe->num_of_bds); - cmn_err(CE_WARN, " num_of_coalesced_segs = %d", LE_16(cqe->num_of_coalesced_segs)); - for (i = 0; i < ETH_TPA_CQE_END_LEN_LIST_SIZE; i++) - cmn_err(CE_WARN, " len_list[%d] = %d", i, LE_16(cqe->len_list[i])); + cmn_err(CE_WARN, " num_of_coalesced_segs = %d", + LE_16(cqe->num_of_coalesced_segs)); + for (i = 0; i < ETH_TPA_CQE_END_LEN_LIST_SIZE; i++) { + cmn_err(CE_WARN, " len_list[%d] = %d", i, + LE_16(cqe->len_list[i])); + } cmn_err(CE_WARN, " ts_delta = %d", LE_32(cqe->ts_delta)); } diff --git a/usr/src/uts/common/io/qede/qede_fp.c b/usr/src/uts/common/io/qede/qede_fp.c index 8018dac365..8457dd82f2 100644 --- a/usr/src/uts/common/io/qede/qede_fp.c +++ b/usr/src/uts/common/io/qede/qede_fp.c @@ -99,17 +99,19 @@ qede_put_bcopy_pkt(qede_tx_ring_t *tx_ring, qede_tx_bcopy_pkt_t *pkt) mutex_exit(&list->lock); } -void qede_print_tx_indexes(qede_tx_ring_t *tx_ring) +void +qede_print_tx_indexes(qede_tx_ring_t *tx_ring) { uint16_t hw_consumer = LE_16(*tx_ring->hw_cons_ptr); uint16_t chain_idx = ecore_chain_get_cons_idx(&tx_ring->tx_bd_ring); hw_consumer &= TX_RING_MASK; chain_idx &= TX_RING_MASK; qede_print_err("!indices: hw_cons %d, chain_cons = %d, sw_prod = %d", - hw_consumer, chain_idx, tx_ring->sw_tx_prod); + hw_consumer, chain_idx, tx_ring->sw_tx_prod); } -void qede_print_rx_indexes(qede_rx_ring_t *rx_ring) +void +qede_print_rx_indexes(qede_rx_ring_t *rx_ring) { u16 hw_bd_cons = HOST_TO_LE_16(*rx_ring->hw_cons_ptr); u16 sw_bd_cons = ecore_chain_get_cons_idx(&rx_ring->rx_cqe_ring); @@ -117,7 +119,7 @@ void qede_print_rx_indexes(qede_rx_ring_t *rx_ring) hw_bd_cons &= (rx_ring->qede->rx_ring_size - 1); sw_bd_cons &= (rx_ring->qede->rx_ring_size - 1); qede_print_err("!RX indices: hw_cons %d, chain_cons = %d", - hw_bd_cons, sw_bd_cons); + hw_bd_cons, sw_bd_cons); } @@ -126,7 +128,8 @@ void qede_print_rx_indexes(qede_rx_ring_t *rx_ring) * NOTE: statu_block dma mem. must be sync'ed * in the interrupt handler */ -int qede_process_tx_completions(qede_tx_ring_t *tx_ring) +int +qede_process_tx_completions(qede_tx_ring_t *tx_ring) { int count = 0; u16 hw_consumer; @@ -172,20 +175,23 @@ int qede_process_tx_completions(qede_tx_ring_t *tx_ring) qede_put_bcopy_pkt(tx_ring, bcopy_pkt); recycle_entry->bcopy_pkt = NULL; } else { - qede_warn(tx_ring->qede, "Invalid completion at index %d", + qede_warn(tx_ring->qede, + "Invalid completion at index %d", sw_consumer); } sw_consumer = (sw_consumer + 1) & TX_RING_MASK; first_bd = - (struct eth_tx_1st_bd *)ecore_chain_consume(&tx_ring->tx_bd_ring); + (struct eth_tx_1st_bd *)ecore_chain_consume( + &tx_ring->tx_bd_ring); bd_consumed++; nbd = first_bd->data.nbds; - while (bd_consumed++ < nbd) + while (bd_consumed++ < nbd) { ecore_chain_consume(&tx_ring->tx_bd_ring); + } chain_idx = ecore_chain_get_cons_idx(&tx_ring->tx_bd_ring); count++; @@ -212,7 +218,6 @@ qede_has_tx_work(qede_tx_ring_t *tx_ring) u16 sw_bd_cons = ecore_chain_get_cons_idx(&tx_ring->tx_bd_ring); if (sw_bd_cons == (hw_bd_cons + 1)) { - //qede_print_err("!%s(): sw_bd_cons == (hw_bd_cons - 1)", __func__); return (0); } return (hw_bd_cons != sw_bd_cons); @@ -242,19 +247,21 @@ qede_set_cksum_flags(mblk_t *mp, iphdr_len_err = (parse_flags >> PARSING_AND_ERR_FLAGS_IPHDRERROR_SHIFT) & PARSING_AND_ERR_FLAGS_IPHDRERROR_MASK; - if (l4_is_calc) { - if (l4_csum_err) { - error = 1; - } else if (iphdr_len_err) { - error = 2; - } else + if (l4_is_calc) { + if (l4_csum_err) { + error = 1; + } else if (iphdr_len_err) { + error = 2; + } else { cksum_flags = HCK_FULLCKSUM_OK | HCK_IPV4_HDRCKSUM_OK; - } + } + } - if (error == 1) - qede_print_err("!%s: got L4 csum error",__func__); - else if (error == 2) - qede_print_err("!%s: got IPHDER csum error" ,__func__); + if (error == 1) { + qede_print_err("!%s: got L4 csum error",__func__); + } else if (error == 2) { + qede_print_err("!%s: got IPHDER csum error" ,__func__); + } mac_hcksum_set(mp, 0, 0, 0, 0, cksum_flags); } @@ -263,7 +270,7 @@ static qede_rx_buffer_t * qede_get_next_rx_buffer(qede_rx_ring_t *rx_ring, uint32_t *free_buffer_count) { - qede_rx_buffer_t * rx_buffer; + qede_rx_buffer_t *rx_buffer; uint32_t num_entries; rx_buffer = qede_get_from_active_list(rx_ring, &num_entries); @@ -280,7 +287,7 @@ qede_get_next_lro_buffer(qede_rx_ring_t *rx_ring, { lro_info->rx_buffer[lro_info->bd_count] = qede_get_next_rx_buffer(rx_ring, - &lro_info->free_buffer_count); + &lro_info->free_buffer_count); lro_info->bd_count++; return (DDI_SUCCESS); } @@ -290,24 +297,28 @@ bool agg_print = B_TRUE; #endif static void qede_lro_start(qede_rx_ring_t *rx_ring, - struct eth_fast_path_rx_tpa_start_cqe *cqe) + struct eth_fast_path_rx_tpa_start_cqe *cqe) { qede_lro_info_t *lro_info; int i, len_on_first_bd, seg_len; lro_info = &rx_ring->lro_info[cqe->tpa_agg_index]; - /*ASSERT(lro_info->agg_state != QEDE_AGG_STATE_NONE);*/ + /* ASSERT(lro_info->agg_state != QEDE_AGG_STATE_NONE); */ #ifdef DEBUG_LRO - if (agg_count++ < 30) qede_dump_start_lro_cqe(cqe); - else agg_print = B_FALSE; + if (agg_count++ < 30) { + qede_dump_start_lro_cqe(cqe); + } else { + agg_print = B_FALSE; + } #endif - memset(lro_info, 0, sizeof(qede_lro_info_t)); + memset(lro_info, 0, sizeof (qede_lro_info_t)); lro_info->agg_state = QEDE_AGG_STATE_START; rx_ring->lro_active_count++; - struct parsing_and_err_flags pars_flags /* Parsing and error flags from the parser */; + + /* Parsing and error flags from the parser */; lro_info->pars_flags = LE_16(cqe->pars_flags.flags); lro_info->pad = LE_16(cqe->placement_offset); @@ -329,8 +340,9 @@ qede_lro_start(qede_rx_ring_t *rx_ring, * multiple buffer descriptors. */ for (i = 0; i < ETH_TPA_CQE_START_LEN_LIST_SIZE; i++) { - if (cqe->ext_bd_len_list[i] == 0) + if (cqe->ext_bd_len_list[i] == 0) { break; + } qede_get_next_lro_buffer(rx_ring, lro_info); } } @@ -338,29 +350,32 @@ qede_lro_start(qede_rx_ring_t *rx_ring, static void qede_lro_cont(qede_rx_ring_t *rx_ring, - struct eth_fast_path_rx_tpa_cont_cqe *cqe) + struct eth_fast_path_rx_tpa_cont_cqe *cqe) { qede_lro_info_t *lro_info; int i; lro_info = &rx_ring->lro_info[cqe->tpa_agg_index]; - /*ASSERT(lro_info->agg_state != QEDE_AGG_STATE_START);*/ + /* ASSERT(lro_info->agg_state != QEDE_AGG_STATE_START); */ #ifdef DEBUG_LRO - if (agg_print) qede_dump_cont_lro_cqe(cqe); + if (agg_print) { + qede_dump_cont_lro_cqe(cqe); + } #endif for (i = 0; i < ETH_TPA_CQE_CONT_LEN_LIST_SIZE; i++) { - if (cqe->len_list[i] == 0) - break; + if (cqe->len_list[i] == 0) { + break; + } qede_get_next_lro_buffer(rx_ring, lro_info); } } static mblk_t * qede_lro_end(qede_rx_ring_t *rx_ring, - struct eth_fast_path_rx_tpa_end_cqe *cqe, - int *pkt_bytes) + struct eth_fast_path_rx_tpa_end_cqe *cqe, + int *pkt_bytes) { qede_lro_info_t *lro_info; mblk_t *head = NULL, *tail = NULL, *mp = NULL; @@ -372,10 +387,12 @@ qede_lro_end(qede_rx_ring_t *rx_ring, lro_info = &rx_ring->lro_info[cqe->tpa_agg_index]; - /*ASSERT(lro_info->agg_state != QEDE_AGG_STATE_START);*/ + /* ASSERT(lro_info->agg_state != QEDE_AGG_STATE_START); */ #ifdef DEBUG_LRO - if (agg_print) qede_dump_end_lro_cqe(cqe); + if (agg_print) { + qede_dump_end_lro_cqe(cqe); + } #endif work_length = total_packet_length = LE_16(cqe->total_packet_len); @@ -384,19 +401,20 @@ qede_lro_end(qede_rx_ring_t *rx_ring, * Get any buffer descriptors for this cqe */ for (i=0; i<ETH_TPA_CQE_END_LEN_LIST_SIZE; i++) { - if (cqe->len_list[i] == 0) + if (cqe->len_list[i] == 0) { break; + } qede_get_next_lro_buffer(rx_ring, lro_info); } - /*ASSERT(lro_info->bd_count != cqe->num_of_bds);*/ + /* ASSERT(lro_info->bd_count != cqe->num_of_bds); */ if (lro_info->free_buffer_count < rx_ring->rx_low_buffer_threshold) { for (i = 0; i < lro_info->bd_count; i++) { - qede_recycle_copied_rx_buffer( + qede_recycle_copied_rx_buffer( lro_info->rx_buffer[i]); - lro_info->rx_buffer[i] = NULL; + lro_info->rx_buffer[i] = NULL; } rx_ring->rx_low_water_cnt++; lro_info->agg_state = QEDE_AGG_STATE_NONE; @@ -419,10 +437,12 @@ qede_lro_end(qede_rx_ring_t *rx_ring, rx_buffer = lro_info->rx_buffer[i]; - bd_len = (work_length > rx_buf_size) ? rx_buf_size : work_length; + bd_len = + (work_length > rx_buf_size) ? rx_buf_size : work_length; if (i == 0 && - (cqe->num_of_bds > 1)) + (cqe->num_of_bds > 1)) { bd_len -= lro_info->pad; + } dma_info = &rx_buffer->dma_info; ddi_dma_sync(dma_info->dma_handle, @@ -446,53 +466,55 @@ qede_lro_end(qede_rx_ring_t *rx_ring, } qede_set_cksum_flags(head, lro_info->pars_flags); -// mac_hcksum_set(head, 0, 0, 0, 0, HCK_FULLCKSUM_OK | HCK_IPV4_HDRCKSUM_OK); rx_ring->rx_lro_pkt_cnt++; rx_ring->lro_active_count--; lro_info->agg_state = QEDE_AGG_STATE_NONE; #ifdef DEBUG_LRO - if (agg_print) qede_dump_mblk_chain_bcont_ptr(rx_ring->qede, head); + if (agg_print) { + qede_dump_mblk_chain_bcont_ptr(rx_ring->qede, head); + } #endif -// memset(lro_info, 0, sizeof(qede_lro_info_t)); *pkt_bytes = (int)total_packet_length; return (head); } -//#define DEBUG_JUMBO #ifdef DEBUG_JUMBO int jumbo_count = 0; bool jumbo_print = B_TRUE; #endif static mblk_t * qede_reg_jumbo_cqe(qede_rx_ring_t *rx_ring, - struct eth_fast_path_rx_reg_cqe *cqe) + struct eth_fast_path_rx_reg_cqe *cqe) { int i; qede_rx_buffer_t *rx_buf, *rx_buffer[ETH_RX_MAX_BUFF_PER_PKT]; mblk_t *mp = NULL, *head = NULL, *tail = NULL; uint32_t free_buffer_count; - uint16_t work_length, pkt_len, bd_len; - uint32_t rx_buf_size = rx_ring->rx_buf_size; + uint16_t work_length; + uint32_t rx_buf_size = rx_ring->rx_buf_size, bd_len; qede_dma_info_t *dma_info; u8 pad = cqe->placement_offset; #ifdef DEBUG_JUMBO - if (jumbo_count++ < 8) qede_dump_reg_cqe(cqe); - else jumbo_print = B_FALSE; + if (jumbo_count++ < 8) { + qede_dump_reg_cqe(cqe); + } else { + jumbo_print = B_FALSE; + } #endif - work_length = pkt_len = HOST_TO_LE_16(cqe->pkt_len); + work_length = HOST_TO_LE_16(cqe->pkt_len); /* * Get the buffers/mps for this cqe */ for (i = 0; i < cqe->bd_num; i++) { rx_buffer[i] = - qede_get_next_rx_buffer(rx_ring, &free_buffer_count); + qede_get_next_rx_buffer(rx_ring, &free_buffer_count); } /* @@ -501,8 +523,9 @@ qede_reg_jumbo_cqe(qede_rx_ring_t *rx_ring, */ if (free_buffer_count < rx_ring->rx_low_buffer_threshold) { - for (i = 0; i < cqe->bd_num; i++) + for (i = 0; i < cqe->bd_num; i++) { qede_recycle_copied_rx_buffer(rx_buffer[i]); + } rx_ring->rx_low_water_cnt++; return (NULL); } @@ -510,14 +533,16 @@ qede_reg_jumbo_cqe(qede_rx_ring_t *rx_ring, for (i = 0; i < cqe->bd_num; i++) { rx_buf = rx_buffer[i]; - bd_len = (work_length > rx_buf_size) ? rx_buf_size : work_length; + bd_len = + (work_length > rx_buf_size) ? rx_buf_size : work_length; /* * Adjust for placement offset * on first bufffer. */ - if (i == 0) + if (i == 0) { bd_len -= pad; + } dma_info = &rx_buf->dma_info; ddi_dma_sync(dma_info->dma_handle, @@ -531,8 +556,9 @@ qede_reg_jumbo_cqe(qede_rx_ring_t *rx_ring, * Adjust for placement offset * on first bufffer. */ - if (i == 0) + if (i == 0) { mp->b_rptr += pad; + } mp->b_wptr = (uchar_t *)((unsigned long)mp->b_rptr + bd_len); @@ -549,7 +575,9 @@ qede_reg_jumbo_cqe(qede_rx_ring_t *rx_ring, qede_set_cksum_flags(head, HOST_TO_LE_16(cqe->pars_flags.flags)); #ifdef DEBUG_JUMBO - if (jumbo_print) qede_dump_mblk_chain_bcont_ptr(rx_ring->qede, head); + if (jumbo_print) { + qede_dump_mblk_chain_bcont_ptr(rx_ring->qede, head); + } #endif rx_ring->rx_jumbo_pkt_cnt++; return (head); @@ -557,9 +585,10 @@ qede_reg_jumbo_cqe(qede_rx_ring_t *rx_ring, static mblk_t * qede_reg_cqe(qede_rx_ring_t *rx_ring, - struct eth_fast_path_rx_reg_cqe *cqe, - int *pkt_bytes) + struct eth_fast_path_rx_reg_cqe *cqe, + int *pkt_bytes) { + qede_t *qede = rx_ring->qede; qede_rx_buffer_t *rx_buffer; uint32_t free_buffer_count; mblk_t *mp; @@ -588,7 +617,7 @@ qede_reg_cqe(qede_rx_ring_t *rx_ring, rx_buffer = qede_get_next_rx_buffer(rx_ring, - &free_buffer_count); + &free_buffer_count); if (free_buffer_count < rx_ring->rx_low_buffer_threshold) { @@ -615,15 +644,17 @@ qede_reg_cqe(qede_rx_ring_t *rx_ring, * drop packet */ qede_print_err("!%s(%d): allocb failed", - __func__, + __func__, rx_ring->qede->instance); + qede->allocbFailures++; + goto freebuf; } /* * We've copied it (or not) and are done with it * so put it back into the passive list. */ ddi_dma_sync(dma_handle, - 0, 0, DDI_DMA_SYNC_FORDEV); + 0, 0, DDI_DMA_SYNC_FORDEV); qede_recycle_copied_rx_buffer(rx_buffer); rx_ring->rx_copy_cnt++; } else { @@ -645,12 +676,17 @@ qede_reg_cqe(qede_rx_ring_t *rx_ring, qede_set_cksum_flags(mp, HOST_TO_LE_16(cqe->pars_flags.flags)); #ifdef DEBUG_JUMBO - if (jumbo_print) qede_dump_mblk_chain_bnext_ptr(rx_ring->qede, mp); + if (jumbo_print) { + qede_dump_mblk_chain_bnext_ptr(rx_ring->qede, mp); + } #endif - rx_ring->rx_reg_pkt_cnt++; return (mp); + +freebuf: + qede_recycle_copied_rx_buffer(rx_buffer); + return (NULL); } /* @@ -662,17 +698,10 @@ static mblk_t * qede_process_rx_ring(qede_rx_ring_t *rx_ring, int nbytes, int npkts) { union eth_rx_cqe *cqe; - struct eth_fast_path_rx_reg_cqe *fp_cqe; u16 last_cqe_consumer = rx_ring->last_cqe_consumer; - u16 rxbd_cons; enum eth_rx_cqe_type cqe_type; - int status = DDI_SUCCESS; u16 sw_comp_cons, hw_comp_cons; - qede_rx_buffer_t *rx_buffer; - char *virt_addr; - u16 len, pad; mblk_t *mp = NULL, *first_mp = NULL, *last_mp = NULL; - ddi_dma_handle_t dma_handle = 0; int pkt_bytes = 0, byte_cnt = 0, pkt_cnt = 0; hw_comp_cons = HOST_TO_LE_16(*rx_ring->hw_cons_ptr); @@ -682,52 +711,55 @@ qede_process_rx_ring(qede_rx_ring_t *rx_ring, int nbytes, int npkts) while (sw_comp_cons != hw_comp_cons) { if ((byte_cnt >= nbytes) || - (pkt_cnt >= npkts)) + (pkt_cnt >= npkts)) { break; + } cqe = (union eth_rx_cqe *) - ecore_chain_consume(&rx_ring->rx_cqe_ring); // Get next element and increment the cons_idx + ecore_chain_consume(&rx_ring->rx_cqe_ring); + /* Get next element and increment the cons_idx */ - (void) ddi_dma_sync(rx_ring->rx_cqe_dmah, // sync this descriptor + (void) ddi_dma_sync(rx_ring->rx_cqe_dmah, last_cqe_consumer, sizeof (*cqe), DDI_DMA_SYNC_FORKERNEL); cqe_type = cqe->fast_path_regular.type; switch (cqe_type) { - case ETH_RX_CQE_TYPE_SLOW_PATH: - ecore_eth_cqe_completion(&rx_ring->qede->edev.hwfns[0], - (struct eth_slow_path_rx_cqe *)cqe); - goto next_cqe; - case ETH_RX_CQE_TYPE_REGULAR: - mp = qede_reg_cqe(rx_ring, - &cqe->fast_path_regular, - &pkt_bytes); - break; - case ETH_RX_CQE_TYPE_TPA_START: - qede_lro_start(rx_ring, - &cqe->fast_path_tpa_start); - goto next_cqe; - case ETH_RX_CQE_TYPE_TPA_CONT: - qede_lro_cont(rx_ring, - &cqe->fast_path_tpa_cont); - goto next_cqe; - case ETH_RX_CQE_TYPE_TPA_END: - mp = qede_lro_end(rx_ring, - &cqe->fast_path_tpa_end, - &pkt_bytes); - break; - default: - if (cqe_type != 0) { + case ETH_RX_CQE_TYPE_SLOW_PATH: + ecore_eth_cqe_completion(&rx_ring->qede->edev.hwfns[0], + (struct eth_slow_path_rx_cqe *)cqe); + goto next_cqe; + case ETH_RX_CQE_TYPE_REGULAR: + mp = qede_reg_cqe(rx_ring, + &cqe->fast_path_regular, + &pkt_bytes); + break; + case ETH_RX_CQE_TYPE_TPA_START: + qede_lro_start(rx_ring, + &cqe->fast_path_tpa_start); + goto next_cqe; + case ETH_RX_CQE_TYPE_TPA_CONT: + qede_lro_cont(rx_ring, + &cqe->fast_path_tpa_cont); + goto next_cqe; + case ETH_RX_CQE_TYPE_TPA_END: + mp = qede_lro_end(rx_ring, + &cqe->fast_path_tpa_end, + &pkt_bytes); + break; + default: + if (cqe_type != 0) { qede_print_err("!%s(%d): cqe_type %x not " "supported", __func__, rx_ring->qede->instance, cqe_type); - } - goto exit_rx; + } + goto exit_rx; } - /* If we arrive here with no mp, + /* + * If we arrive here with no mp, * then we hit an RX buffer threshold * where we had to drop the packet and * give the buffers back to the device. @@ -746,11 +778,12 @@ qede_process_rx_ring(qede_rx_ring_t *rx_ring, int nbytes, int npkts) pkt_cnt++; byte_cnt += pkt_bytes; next_cqe: - ecore_chain_recycle_consumed(&rx_ring->rx_cqe_ring); // increment prod_idx + ecore_chain_recycle_consumed(&rx_ring->rx_cqe_ring); last_cqe_consumer = sw_comp_cons; sw_comp_cons = ecore_chain_get_cons_idx(&rx_ring->rx_cqe_ring); - if(!(qede_has_rx_work(rx_ring))) + if (!(qede_has_rx_work(rx_ring))) { ecore_sb_update_sb_idx(rx_ring->fp->sb_info); + } hw_comp_cons = HOST_TO_LE_16(*rx_ring->hw_cons_ptr); } rx_ring->rx_pkt_cnt += pkt_cnt; @@ -795,16 +828,18 @@ qede_process_fastpath(qede_fastpath_t *fp, } } - if(!(qede_has_rx_work(rx_ring))) + if (!(qede_has_rx_work(rx_ring))) { ecore_sb_update_sb_idx(fp->sb_info); + } rx_ring = fp->rx_ring; if (qede_has_rx_work(rx_ring)) { mutex_enter(&rx_ring->rx_lock); mp = qede_process_rx_ring(rx_ring, nbytes, npkts); - if (mp) + if (mp) { *work_done += 1; + } mutex_exit(&rx_ring->rx_lock); } @@ -821,7 +856,8 @@ qede_process_fastpath(qede_fastpath_t *fp, static void qede_pkt_parse_lso_headers(qede_tx_pktinfo_t *pktinfo, mblk_t *mp) { - struct ether_header *eth_hdr = (struct ether_header *)(void *)mp->b_rptr; + struct ether_header *eth_hdr = + (struct ether_header *)(void *)mp->b_rptr; ipha_t *ip_hdr; struct tcphdr *tcp_hdr; @@ -874,12 +910,14 @@ qede_get_pkt_offload_info(qede_t *qede, mblk_t *mp, } static void +/* LINTED E_FUNC_ARG_UNUSED */ qede_get_pkt_info(qede_t *qede, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) { mblk_t *bp; size_t size; - int i = 0; + struct ether_header *eth_hdr = + (struct ether_header *)(void *)mp->b_rptr; pktinfo->total_len = 0; pktinfo->mblk_no = 0; @@ -897,6 +935,16 @@ qede_get_pkt_info(qede_t *qede, mblk_t *mp, pktinfo->total_len += size; pktinfo->mblk_no++; } + /* mac header type and len */ + if (ntohs(eth_hdr->ether_type) == ETHERTYPE_IP) { + pktinfo->ether_type = ntohs(eth_hdr->ether_type); + pktinfo->mac_hlen = sizeof (struct ether_header); + } else if (ntohs(eth_hdr->ether_type) == ETHERTYPE_VLAN) { + struct ether_vlan_header *vlan_hdr = + (struct ether_vlan_header *)(void *)mp->b_rptr; + pktinfo->ether_type = ntohs(vlan_hdr->ether_type); + pktinfo->mac_hlen = sizeof (struct ether_vlan_header); + } } @@ -952,8 +1000,9 @@ qede_tx_bcopy(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) for (bp = mp; bp != NULL; bp = bp->b_cont) { mblen = MBLKL(bp); - if (mblen == 0) + if (mblen == 0) { continue; + } bcopy(bp->b_rptr, txb, mblen); txb += mblen; } @@ -983,13 +1032,11 @@ qede_tx_bcopy(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) (1 << ETH_TX_1ST_BD_FLAGS_START_BD_SHIFT); if (pktinfo->cksum_flags & HCK_IPV4_HDRCKSUM) { - //qede_info(tx_ring->qede, "HCK_IPV4_HDRCKSUM on pkt"); first_bd->data.bd_flags.bitfields |= (1 << ETH_TX_1ST_BD_FLAGS_IP_CSUM_SHIFT); } if (pktinfo->cksum_flags & HCK_FULLCKSUM) { - //qede_info(tx_ring->qede, "HCK_FULLCKSUM used on pkt mp %p", mp); first_bd->data.bd_flags.bitfields |= (1 << ETH_TX_1ST_BD_FLAGS_L4_CSUM_SHIFT); } @@ -999,7 +1046,8 @@ qede_tx_bcopy(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) pktinfo->total_len); first_bd->data.bitfields |= - (pktinfo->total_len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK) << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT; + (pktinfo->total_len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK) + << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT; tx_ring->tx_db.data.bd_prod = HOST_TO_LE_16(ecore_chain_get_prod_idx(&tx_ring->tx_bd_ring)); @@ -1031,13 +1079,13 @@ qede_tx_mapped(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) { enum qede_xmit_status status = XMIT_FAILED; int ret; - qede_dma_handles_list_t *dmah_list = &tx_ring->dmah_list; - qede_dma_handle_entry_t *dmah_entry = NULL, *head = NULL, *tail = NULL, *hdl; + qede_dma_handle_entry_t *dmah_entry = NULL; + qede_dma_handle_entry_t *head = NULL, *tail = NULL, *hdl; struct eth_tx_1st_bd *first_bd; - struct eth_tx_2nd_bd *second_bd; - struct eth_tx_3rd_bd *third_bd; + struct eth_tx_2nd_bd *second_bd = 0; + struct eth_tx_3rd_bd *third_bd = 0; struct eth_tx_bd *tx_data_bd; - struct eth_tx_bd local_bd[64] = {0}; + struct eth_tx_bd local_bd[64] = { 0 }; ddi_dma_cookie_t cookie[64]; u32 ncookies, total_cookies = 0, max_cookies = 0, index = 0; ddi_dma_handle_t dma_handle; @@ -1046,7 +1094,7 @@ qede_tx_mapped(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) bool is_premapped = B_FALSE; u64 dma_premapped = 0, dma_bound = 0; u32 hdl_reserved = 0; - u32 nbd = 0; + u8 nbd = 0; int i, bd_index; u16 last_producer; qede_tx_recycle_list_t *tx_recycle_list = tx_ring->tx_recycle_list; @@ -1057,7 +1105,6 @@ qede_tx_mapped(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) /* * For tso pkt, we can use as many as 255 bds */ - //max_cookies = 255; max_cookies = ETH_TX_MAX_BDS_PER_NON_LSO_PACKET - 1; qede_pkt_parse_lso_headers(pktinfo, mp); } else { @@ -1069,8 +1116,9 @@ qede_tx_mapped(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) for (bp = mp; bp != NULL; bp = bp->b_cont) { mblen = MBLKL(bp); - if (mblen == 0) + if (mblen == 0) { continue; + } is_premapped = B_FALSE; /* * If the mblk is premapped then get the @@ -1115,11 +1163,13 @@ qede_tx_mapped(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) != DDI_DMA_MAPPED) { #ifdef DEBUG_PULLUP - qede_info(tx_ring->qede, "addr_bind() failed for " - "handle %p, len %d mblk_no %d tot_len 0x%x use_lso %d", dmah_entry->dma_handle, - mblen, pktinfo->mblk_no, pktinfo->total_len, pktinfo->use_lso); + qede_info(tx_ring->qede, "addr_bind() failed for " + "handle %p, len %d mblk_no %d tot_len 0x%x" + " use_lso %d", dmah_entry->dma_handle, + mblen, pktinfo->mblk_no, pktinfo->total_len, + pktinfo->use_lso); - qede_info(tx_ring->qede, "Falling back to pullup"); + qede_info(tx_ring->qede, "Falling back to pullup"); #endif status = XMIT_FALLBACK_PULLUP; tx_ring->tx_bind_fail++; @@ -1149,7 +1199,8 @@ qede_tx_mapped(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) if (total_cookies > max_cookies) { tx_ring->tx_too_many_cookies++; #ifdef DEBUG_PULLUP - qede_info(tx_ring->qede, "total_cookies > max_cookies, " + qede_info(tx_ring->qede, + "total_cookies > max_cookies, " "pktlen %d, mb num %d", pktinfo->total_len, pktinfo->mblk_no); #endif @@ -1181,7 +1232,7 @@ qede_tx_mapped(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) goto err_map_sec; } - if (total_cookies > max_cookies){ + if (total_cookies > max_cookies) { tx_ring->tx_too_many_cookies++; status = XMIT_TOO_MANY_COOKIES; goto err_map_sec; @@ -1243,7 +1294,8 @@ qede_tx_mapped(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) bd_index++; } else if (first_bd->nbytes < pktinfo->total_hlen) { #ifdef DEBUG_PULLUP - qede_info(tx_ring->qede, "Headers not in single bd"); + qede_info(tx_ring->qede, + "Headers not in single bd"); #endif status = XMIT_FALLBACK_PULLUP; goto err_map_sec; @@ -1281,7 +1333,8 @@ qede_tx_mapped(qede_tx_ring_t *tx_ring, mblk_t *mp, qede_tx_pktinfo_t *pktinfo) } else { nbd = total_cookies; first_bd->data.bitfields |= - (pktinfo->total_len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK) << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT; + (pktinfo->total_len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK) + << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT; } first_bd->data.nbds = nbd; @@ -1353,8 +1406,9 @@ err_map_sec: hdl = hdl->next; } - if (head != NULL) + if (head != NULL) { qede_put_dmah_entries(tx_ring, head); + } return (status); } @@ -1363,11 +1417,11 @@ static enum qede_xmit_status qede_send_tx_packet(qede_t *qede, qede_tx_ring_t *tx_ring, mblk_t *mp) { boolean_t force_pullup = B_FALSE; - enum qede_xmit_status status; + enum qede_xmit_status status = XMIT_FAILED; enum qede_xmit_mode xmit_mode = USE_BCOPY; qede_tx_pktinfo_t pktinfo; - u16 cons, prod; mblk_t *original_mp = NULL, *pulled_up_mp = NULL; + struct ether_vlan_header *ethvhdr; mutex_enter(&tx_ring->tx_lock); if (ecore_chain_get_elem_left(&tx_ring->tx_bd_ring) < @@ -1429,10 +1483,11 @@ do_pullup: qede_get_pkt_info(qede, mp, &pktinfo); - if ((!pktinfo.use_lso) && - (pktinfo.total_len > (qede->mtu + QEDE_MAX_ETHER_HDR))) { - qede_info(tx_ring->qede, "Packet drop as packet len 0x%x > 0x%x", - pktinfo.total_len, (qede->mtu + QEDE_MAX_ETHER_HDR)); + if ((!pktinfo.use_lso) && + (pktinfo.total_len > (qede->mtu + pktinfo.mac_hlen))) { + qede_info(tx_ring->qede, + "Packet drop as packet len 0x%x > 0x%x", + pktinfo.total_len, (qede->mtu + QEDE_MAX_ETHER_HDR)); status = XMIT_FAILED; goto exit; } @@ -1440,7 +1495,8 @@ do_pullup: #ifdef DEBUG_PULLUP if (force_pullup) { - qede_print_err("!%s: mp %p, pktinfo : total_len %d, mblk_no %d, ether_type %d\n" + qede_print_err("!%s: mp %p, pktinfo : total_len %d," + " mblk_no %d, ether_type %d\n" "mac_hlen %d, ip_hlen %d, l4_hlen %d\n" "l4_proto %d, use_cksum:use_lso %d:%d mss %d", __func__, mp, pktinfo.total_len, pktinfo.mblk_no, pktinfo.ether_type, @@ -1451,22 +1507,26 @@ do_pullup: #endif #ifdef DEBUG_PREMAP - if (DBLK_IS_PREMAPPED(mp->b_datap)) + if (DBLK_IS_PREMAPPED(mp->b_datap)) { qede_print_err("!%s(%d): mp %p id PREMAPPMED", __func__, qede->instance); + } #endif #ifdef DBLK_DMA_PREMAP if (DBLK_IS_PREMAPPED(mp->b_datap) || - pktinfo.total_len > qede->tx_bcopy_threshold) + pktinfo.total_len > qede->tx_bcopy_threshold) { xmit_mode = USE_DMA_BIND; + } #else - if (pktinfo.total_len > qede->tx_bcopy_threshold) + if (pktinfo.total_len > qede->tx_bcopy_threshold) { xmit_mode = USE_DMA_BIND; + } #endif - if (pktinfo.total_len <= qede->tx_bcopy_threshold) + if (pktinfo.total_len <= qede->tx_bcopy_threshold) { xmit_mode = USE_BCOPY; + } /* * if mac + ip hdr not in one contiguous block, @@ -1515,14 +1575,15 @@ do_pullup: if (xmit_mode == USE_DMA_BIND) { status = qede_tx_mapped(tx_ring, mp, &pktinfo); if (status == XMIT_DONE) { - if (pktinfo.use_lso) + if (pktinfo.use_lso) { tx_ring->tx_lso_pkt_count++; - else if(pktinfo.total_len > 1518) + } else if(pktinfo.total_len > 1518) { tx_ring->tx_jumbo_pkt_count++; + } tx_ring->tx_mapped_pkts++; goto exit; } else if ((status == XMIT_TOO_MANY_COOKIES || - (status == XMIT_FALLBACK_PULLUP)) && !force_pullup) { + (status == XMIT_FALLBACK_PULLUP)) && !force_pullup) { xmit_mode = USE_PULLUP; } else { status = XMIT_FAILED; @@ -1570,7 +1631,8 @@ exit: */ if (pulled_up_mp) { #ifdef DEBUG_PULLUP - qede_info(qede, "success, free ori mp %p", original_mp); + qede_info(qede, + "success, free ori mp %p", original_mp); #endif freemsg(original_mp); } @@ -1612,7 +1674,8 @@ register ub4 initval; /* the previous hash, or an arbitrary value */ c = initval; /* the previous hash value */ /* handle most of the key */ - while (len >= 12) { + while (len >= 12) + { a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24)); b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24)); c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24)); @@ -1624,30 +1687,42 @@ register ub4 initval; /* the previous hash, or an arbitrary value */ /* handle the last 11 bytes */ c += length; /* all the case statements fall through */ - switch (len) { - /* FALLTHRU */ - case 11: c += ((ub4)k[10]<<24); - /* FALLTHRU */ - case 10: c += ((ub4)k[9]<<16); - /* FALLTHRU */ - case 9 : c += ((ub4)k[8]<<8); + switch (len) + { + /* FALLTHRU */ + case 11: + c += ((ub4)k[10]<<24); + /* FALLTHRU */ + case 10: + c += ((ub4)k[9]<<16); + /* FALLTHRU */ + case 9 : + c += ((ub4)k[8]<<8); /* the first byte of c is reserved for the length */ - /* FALLTHRU */ - case 8 : b += ((ub4)k[7]<<24); - /* FALLTHRU */ - case 7 : b += ((ub4)k[6]<<16); - /* FALLTHRU */ - case 6 : b += ((ub4)k[5]<<8); - /* FALLTHRU */ - case 5 : b += k[4]; - /* FALLTHRU */ - case 4 : a += ((ub4)k[3]<<24); - /* FALLTHRU */ - case 3 : a += ((ub4)k[2]<<16); - /* FALLTHRU */ - case 2 : a += ((ub4)k[1]<<8); - /* FALLTHRU */ - case 1 : a += k[0]; + /* FALLTHRU */ + case 8 : + b += ((ub4)k[7]<<24); + /* FALLTHRU */ + case 7 : + b += ((ub4)k[6]<<16); + /* FALLTHRU */ + case 6 : + b += ((ub4)k[5]<<8); + /* FALLTHRU */ + case 5 : + b += k[4]; + /* FALLTHRU */ + case 4 : + a += ((ub4)k[3]<<24); + /* FALLTHRU */ + case 3 : + a += ((ub4)k[2]<<16); + /* FALLTHRU */ + case 2 : + a += ((ub4)k[1]<<8); + /* FALLTHRU */ + case 1 : + a += k[0]; /* case 0: nothing left to add */ } mix(a, b, c); @@ -1674,8 +1749,9 @@ qede_hash_get_txq(qede_t *qede, caddr_t bp) uint16_t dest_port = 0; uint8_t key[12]; - if (qede->num_fp == 1) + if (qede->num_fp == 1) { return (tx_ring_id); + } ethhdr = (struct ether_header *)((void *)bp); ethvhdr = (struct ether_vlan_header *)((void *)bp); @@ -1771,7 +1847,9 @@ qede_ring_tx(void *arg, mblk_t *mp) goto exit; } - if (!qede->params.link_state){ + if (!qede->params.link_state) { + qede_print_err("!%s(%d): Link !up for xmit", + __func__, qede->instance); goto exit; } @@ -1788,7 +1866,8 @@ qede_ring_tx(void *arg, mblk_t *mp) tx_ring = fp->tx_ring[0]; if (qede->num_tc > 1) { - qede_info(qede, "Traffic classes(%d) > 1 not supported", + qede_info(qede, + "Traffic classes(%d) > 1 not supported", qede->num_tc); goto exit; } @@ -1802,11 +1881,9 @@ qede_ring_tx(void *arg, mblk_t *mp) mp = next; } else if (status == XMIT_PAUSE_QUEUE) { tx_ring->tx_ring_pause++; - //qede_info(qede, "Pausing tx queue"); mp->b_next = next; break; } else if (status == XMIT_FAILED) { - //qede_info(qede, "Failed tx"); goto exit; } } diff --git a/usr/src/uts/common/io/qede/qede_fp.h b/usr/src/uts/common/io/qede/qede_fp.h index 7bd454e7da..95e14748d4 100644 --- a/usr/src/uts/common/io/qede/qede_fp.h +++ b/usr/src/uts/common/io/qede/qede_fp.h @@ -33,6 +33,9 @@ * limitations under the License. */ +#ifndef _QEDE_FP_H +#define _QEDE_FP_H + #define RX_INDICATE_UPSTREAM(rx_ring, mp) \ mac_rx_ring(rx_ring->qede->mac_handle, \ rx_ring->mac_ring_handle, mp, \ @@ -40,8 +43,8 @@ #define MAX_TX_RING_SIZE 8192 -#define RESUME_TX(tx_ring) mac_tx_ring_update(tx_ring->qede->mac_handle, \ - tx_ring->mac_ring_handle) +#define RESUME_TX(tx_ring) mac_tx_ring_update(tx_ring->qede->mac_handle, \ + tx_ring->mac_ring_handle) #define CQE_FLAGS_ERR (PARSING_AND_ERR_FLAGS_IPHDRERROR_MASK << \ PARSING_AND_ERR_FLAGS_IPHDRERROR_SHIFT | \ @@ -65,7 +68,6 @@ #endif #ifndef QEDE_TX_MAP_PATH_PAUSE_THRESHOLD -//#define QEDE_TX_MAP_PATH_PAUSE_THRESHOLD ETH_TX_MAX_BDS_PER_NON_LSO_PACKET #define QEDE_TX_MAP_PATH_PAUSE_THRESHOLD 128 #endif @@ -135,19 +137,19 @@ typedef struct qede_tx_pktinfo_s { } qede_tx_pktinfo_t; typedef struct qede_tx_bcopy_pkt_s { - mblk_t *mp; + mblk_t *mp; ddi_acc_handle_t acc_handle; ddi_dma_handle_t dma_handle; u32 ncookies; u32 offset; u64 phys_addr; - void *virt_addr; + void *virt_addr; u32 padding; } qede_tx_bcopy_pkt_t; typedef struct qede_tx_bcopy_list_s { - qede_tx_bcopy_pkt_t *bcopy_pool; - qede_tx_bcopy_pkt_t *free_list[MAX_TX_RING_SIZE]; + qede_tx_bcopy_pkt_t *bcopy_pool; + qede_tx_bcopy_pkt_t *free_list[MAX_TX_RING_SIZE]; u16 head; u16 tail; kmutex_t lock; @@ -155,7 +157,7 @@ typedef struct qede_tx_bcopy_list_s { } qede_tx_bcopy_list_t; typedef struct qede_dma_handle_entry_s { - mblk_t *mp; + mblk_t *mp; ddi_dma_handle_t dma_handle; struct qede_dma_handle_entry_s *next; } qede_dma_handle_entry_t; @@ -170,8 +172,10 @@ typedef struct qede_dma_handles_list_s { } qede_dma_handles_list_t; typedef struct qede_tx_recycle_list_s { - qede_tx_bcopy_pkt_t *bcopy_pkt; + qede_tx_bcopy_pkt_t *bcopy_pkt; qede_dma_handle_entry_t *dmah_entry; } qede_tx_recycle_list_t; mblk_t *qede_ring_tx(void *arg, mblk_t *mp); + +#endif /* !_QEDE_FP_H */ diff --git a/usr/src/uts/common/io/qede/qede_gld.c b/usr/src/uts/common/io/qede/qede_gld.c index 4098409c17..cb3dfaa7d7 100644 --- a/usr/src/uts/common/io/qede/qede_gld.c +++ b/usr/src/uts/common/io/qede/qede_gld.c @@ -33,14 +33,13 @@ * limitations under the License. */ -/* - * Copyright 2018 Joyent, Inc. - */ #include "qede.h" -#define FP_LOCK(ptr) mutex_enter(&ptr->fp_lock); -#define FP_UNLOCK(ptr) mutex_exit(&ptr->fp_lock); +#define FP_LOCK(ptr) \ +mutex_enter(&ptr->fp_lock); +#define FP_UNLOCK(ptr) \ +mutex_exit(&ptr->fp_lock); int qede_ucst_find(qede_t *qede, const uint8_t *mac_addr) @@ -48,8 +47,8 @@ qede_ucst_find(qede_t *qede, const uint8_t *mac_addr) int slot; for(slot = 0; slot < qede->ucst_total; slot++) { - if(bcmp(qede->ucst_mac[slot].mac_addr.ether_addr_octet, - mac_addr, ETHERADDRL) == 0) { + if (bcmp(qede->ucst_mac[slot].mac_addr.ether_addr_octet, + mac_addr, ETHERADDRL) == 0) { return (slot); } } @@ -62,7 +61,7 @@ qede_set_mac_addr(qede_t *qede, uint8_t *mac_addr, uint8_t fl) { struct ecore_filter_ucast params; - memset(¶ms, 0, sizeof(params)); + memset(¶ms, 0, sizeof (params)); params.opcode = fl; params.type = ECORE_FILTER_MAC; @@ -70,73 +69,82 @@ qede_set_mac_addr(qede_t *qede, uint8_t *mac_addr, uint8_t fl) params.is_tx_filter = true; COPY_ETH_ADDRESS(mac_addr, params.mac); - //return ecore_filter_ucast_cmd(&qede->edev, ¶ms, ECORE_SPQ_MODE_CB, NULL); - return ecore_filter_ucast_cmd(&qede->edev, ¶ms, ECORE_SPQ_MODE_EBLOCK, NULL); + return (ecore_filter_ucast_cmd(&qede->edev, + ¶ms, ECORE_SPQ_MODE_EBLOCK, NULL)); } static int qede_add_macaddr(qede_t *qede, uint8_t *mac_addr) { - int i , ret = 0; + int i, ret = 0; i = qede_ucst_find(qede, mac_addr); - if(i != -1) { - qede_info(qede, "mac addr already added %d\n", qede->ucst_avail); - return 0; + if (i != -1) { + /* LINTED E_ARGUMENT_MISMATCH */ + qede_info(qede, "mac addr already added %d\n", + qede->ucst_avail); + return (0); } - if(qede->ucst_avail == 0) { + if (qede->ucst_avail == 0) { qede_info(qede, "add macaddr ignored \n"); return (ENOSPC); } for (i = 0; i < qede->ucst_total; i++) { - if (qede->ucst_mac[i].set == 0) + if (qede->ucst_mac[i].set == 0) { break; + } } if (i >= qede->ucst_total) { qede_info(qede, "add macaddr ignored no space"); return (ENOSPC); } - /*ret = qede_set_mac_addr(qede, (uint8_t *)qede->ether_addr, ECORE_FILTER_REMOVE); + ret = qede_set_mac_addr(qede, (uint8_t *)mac_addr, ECORE_FILTER_ADD); if (ret == 0) { - qede_info(qede, "!qede_add_macaddr remove primary mac passed qede %p\n", qede);*/ - ret = qede_set_mac_addr(qede, (uint8_t *)mac_addr, ECORE_FILTER_ADD); - if (ret == 0) { - bcopy(mac_addr, qede->ucst_mac[i].mac_addr.ether_addr_octet, - ETHERADDRL); - qede->ucst_mac[i].set = 1; - qede->ucst_avail--; - qede_info(qede, " add macaddr passed for addr " - "%02x:%02x:%02x:%02x:%02x:%02x", - mac_addr[0], mac_addr[1], - mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); - } else { - - qede_info(qede, "add macaddr failed for addr " - "%02x:%02x:%02x:%02x:%02x:%02x", - mac_addr[0], mac_addr[1], - mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); - - } - if(qede->ucst_avail == (qede->ucst_total -1)) { - u8 bcast_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff }; + bcopy(mac_addr, + qede->ucst_mac[i].mac_addr.ether_addr_octet, + ETHERADDRL); + qede->ucst_mac[i].set = 1; + qede->ucst_avail--; + /* LINTED E_ARGUMENT_MISMATCH */ + qede_info(qede, " add macaddr passed for addr " + "%02x:%02x:%02x:%02x:%02x:%02x", + mac_addr[0], mac_addr[1], + mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); + } else { + /* LINTED E_ARGUMENT_MISMATCH */ + qede_info(qede, "add macaddr failed for addr " + "%02x:%02x:%02x:%02x:%02x:%02x", + mac_addr[0], mac_addr[1], + mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); + + } + if (qede->ucst_avail == (qede->ucst_total -1)) { + u8 bcast_addr[] = + { + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff + }; for (i = 0; i < qede->ucst_total; i++) { if (qede->ucst_mac[i].set == 0) break; } - ret = qede_set_mac_addr(qede, (uint8_t *)bcast_addr, ECORE_FILTER_ADD); + ret = qede_set_mac_addr(qede, + (uint8_t *)bcast_addr, ECORE_FILTER_ADD); if (ret == 0) { - bcopy(bcast_addr, qede->ucst_mac[i].mac_addr.ether_addr_octet, - ETHERADDRL); + bcopy(bcast_addr, + qede->ucst_mac[i].mac_addr.ether_addr_octet, + ETHERADDRL); qede->ucst_mac[i].set = 1; qede->ucst_avail--; } else { + /* LINTED E_ARGUMENT_MISMATCH */ qede_info(qede, "add macaddr failed for addr " - "%02x:%02x:%02x:%02x:%02x:%02x", - mac_addr[0], mac_addr[1], - mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); + "%02x:%02x:%02x:%02x:%02x:%02x", + mac_addr[0], mac_addr[1], + mac_addr[2], mac_addr[3], mac_addr[4], + mac_addr[5]); } } @@ -155,9 +163,9 @@ qede_add_mac_addr(void *arg, const uint8_t *mac_addr) { qede_mac_group_t *rx_group = (qede_mac_group_t *)arg; qede_t *qede = rx_group->qede; - int group_index = rx_group->group_index; int ret = DDI_SUCCESS; + /* LINTED E_ARGUMENT_MISMATCH */ qede_info(qede, " mac addr :" MAC_STRING, MACTOSTR(mac_addr)); mutex_enter(&qede->gld_lock); @@ -174,15 +182,18 @@ qede_add_mac_addr(void *arg, const uint8_t *mac_addr) } static int -qede_rem_macaddr(qede_t * qede, uint8_t *mac_addr) +qede_rem_macaddr(qede_t *qede, uint8_t *mac_addr) { int ret = 0; int i; i = qede_ucst_find(qede, mac_addr); - if(i == -1) { - qede_info(qede, "mac addr not there to remove", MAC_STRING, MACTOSTR(mac_addr)); - return 0; + if (i == -1) { + /* LINTED E_ARGUMENT_MISMATCH */ + qede_info(qede, + "mac addr not there to remove", + MAC_STRING, MACTOSTR(mac_addr)); + return (0); } if (qede->ucst_mac[i].set == 0) { return (EINVAL); @@ -193,9 +204,11 @@ qede_rem_macaddr(qede_t * qede, uint8_t *mac_addr) qede->ucst_mac[i].set = 0; qede->ucst_avail++; } else { - qede_info(qede, "mac addr remove failed", MAC_STRING, MACTOSTR(mac_addr)); + /* LINTED E_ARGUMENT_MISMATCH */ + qede_info(qede, "mac addr remove failed", + MAC_STRING, MACTOSTR(mac_addr)); } - return ret; + return (ret); } @@ -205,9 +218,9 @@ qede_rem_mac_addr(void *arg, const uint8_t *mac_addr) { qede_mac_group_t *rx_group = (qede_mac_group_t *)arg; qede_t *qede = rx_group->qede; - int group_index = rx_group->group_index; int ret = DDI_SUCCESS; + /* LINTED E_ARGUMENT_MISMATCH */ qede_info(qede, "mac addr remove:" MAC_STRING, MACTOSTR(mac_addr)); mutex_enter(&qede->gld_lock); if (qede->qede_state == QEDE_STATE_SUSPENDED) { @@ -216,7 +229,7 @@ qede_rem_mac_addr(void *arg, const uint8_t *mac_addr) } ret = qede_rem_macaddr(qede, (uint8_t *)mac_addr); mutex_exit(&qede->gld_lock); - return ret; + return (ret); } @@ -231,7 +244,7 @@ qede_tx_ring_stat(mac_ring_driver_t rh, uint_t stat, uint64_t *val) if (qede->qede_state == QEDE_STATE_SUSPENDED) - return(ECANCELED); + return (ECANCELED); switch (stat) { case MAC_STAT_OBYTES: @@ -265,20 +278,20 @@ qede_rx_ring_poll(void *arg, int poll_bytes) mblk_t *mp = NULL; int work_done = 0; qede_t *qede = fp->qede; - //qede_print("!%s(%d): called", __func__,fp->qede->instance); - if (poll_bytes == 0) + if (poll_bytes == 0) { return (NULL); + } mutex_enter(&fp->fp_lock); -// mp = qede_poll_fastpath(fp, poll_bytes, poll_pkts); qede->intrSbPollCnt[fp->vect_info->vect_index]++; mp = qede_process_fastpath(fp, poll_bytes, poll_pkts, &work_done); - if (mp != NULL) + if (mp != NULL) { fp->rx_ring->rx_poll_cnt++; - else if((mp == NULL) && (work_done == 0)) + } else if ((mp == NULL) && (work_done == 0)) { qede->intrSbPollNoChangeCnt[fp->vect_info->vect_index]++; + } mutex_exit(&fp->fp_lock); return (mp); @@ -295,7 +308,7 @@ qede_rx_ring_intr_enable(mac_intr_handle_t rh) qede_fastpath_t *fp = (qede_fastpath_t *)rh; mutex_enter(&fp->qede->drv_lock); - if(!fp->sb_phys && (fp->sb_dma_handle == NULL)) { + if (!fp->sb_phys && (fp->sb_dma_handle == NULL)) { mutex_exit(&fp->qede->drv_lock); return (DDI_FAILURE); } @@ -319,7 +332,7 @@ qede_rx_ring_intr_disable(mac_intr_handle_t rh) qede_fastpath_t *fp = (qede_fastpath_t *)rh; mutex_enter(&fp->qede->drv_lock); - if(!fp->sb_phys && (fp->sb_dma_handle == NULL)) { + if (!fp->sb_phys && (fp->sb_dma_handle == NULL)) { mutex_exit(&fp->qede->drv_lock); return (DDI_FAILURE); } @@ -340,22 +353,21 @@ qede_rx_ring_stat(mac_ring_driver_t rh, uint_t stat, uint64_t *val) qede_t *qede = fp->qede; qede_rx_ring_t *rx_ring = fp->rx_ring; - /*qede_print("!%s(%d): called", __func__,qede->instance);*/ - // Stub - if (qede->qede_state == QEDE_STATE_SUSPENDED) + if (qede->qede_state == QEDE_STATE_SUSPENDED) { return (ECANCELED); + } switch (stat) { - case MAC_STAT_RBYTES: - *val = rx_ring->rx_byte_cnt; - break; - case MAC_STAT_IPACKETS: - *val = rx_ring->rx_pkt_cnt; - break; - default: - *val = 0; - ret = ENOTSUP; - break; + case MAC_STAT_RBYTES: + *val = rx_ring->rx_byte_cnt; + break; + case MAC_STAT_IPACKETS: + *val = rx_ring->rx_pkt_cnt; + break; + default: + *val = 0; + ret = ENOTSUP; + break; } return (ret); @@ -368,15 +380,16 @@ qede_get_global_ring_index(qede_t *qede, int gindex, int rindex) qede_rx_ring_t *rx_ring; int i = 0; - /*qede_print("!%s(%d): called", __func__,qede->instance);*/ for (i = 0; i < qede->num_fp; i++) { fp = &qede->fp_array[i]; rx_ring = fp->rx_ring; - if (rx_ring->group_index == gindex) + if (rx_ring->group_index == gindex) { rindex--; - if (rindex < 0) + } + if (rindex < 0) { return (i); + } } return (-1); @@ -442,9 +455,10 @@ qede_fill_ring(void *arg, mac_ring_type_t rtype, const int group_index, */ ASSERT(global_ring_index >= 0); - if (rh == NULL) + if (rh == NULL) { cmn_err(CE_WARN, "!rx ring(%d) ring handle NULL", global_ring_index); + } fp = &qede->fp_array[global_ring_index]; rx_ring = fp->rx_ring; @@ -539,8 +553,9 @@ qede_fill_group(void *arg, mac_ring_type_t rtype, const int index, infop->mgi_remmac = qede_rem_mac_addr; infop->mgi_count = qede->num_fp; #ifndef ILLUMOS - if (index == 0) + if (index == 0) { infop->mgi_flags = MAC_GROUP_DEFAULT; + } #endif break; @@ -568,8 +583,9 @@ qede_fill_group(void *arg, mac_ring_type_t rtype, const int index, infop->mgi_count = qede->num_fp; #ifndef ILLUMOS - if (index == 0) + if (index == 0) { infop->mgi_flags = MAC_GROUP_DEFAULT; + } #endif break; } @@ -582,93 +598,93 @@ qede_fill_group(void *arg, mac_ring_type_t rtype, const int index, static int qede_transceiver_info(void *arg, uint_t id, mac_transceiver_info_t *infop) { - qede_t *qede = arg; - struct ecore_dev *edev = &qede->edev; - struct ecore_hwfn *hwfn; - struct ecore_ptt *ptt; - uint32_t transceiver_state; - - if (id >= edev->num_hwfns || arg == NULL || infop == NULL) - return (EINVAL); - - hwfn = &edev->hwfns[id]; - ptt = ecore_ptt_acquire(hwfn); - if (ptt == NULL) { - return (EIO); - } - - /* - * Use the underlying raw API to get this information. While the - * ecore_phy routines have some ways of getting to this information, it - * ends up writing the raw data as ASCII characters which doesn't help - * us one bit. - */ - transceiver_state = ecore_rd(hwfn, ptt, hwfn->mcp_info->port_addr + - OFFSETOF(struct public_port, transceiver_data)); - transceiver_state = GET_FIELD(transceiver_state, ETH_TRANSCEIVER_STATE); - ecore_ptt_release(hwfn, ptt); - - if ((transceiver_state & ETH_TRANSCEIVER_STATE_PRESENT) != 0) { - mac_transceiver_info_set_present(infop, B_TRUE); - /* - * Based on our testing, the ETH_TRANSCEIVER_STATE_VALID flag is - * not set, so we cannot rely on it. Instead, we have found that - * the ETH_TRANSCEIVER_STATE_UPDATING will be set when we cannot - * use the transceiver. - */ - if ((transceiver_state & ETH_TRANSCEIVER_STATE_UPDATING) != 0) { - mac_transceiver_info_set_usable(infop, B_FALSE); - } else { - mac_transceiver_info_set_usable(infop, B_TRUE); - } - } else { - mac_transceiver_info_set_present(infop, B_FALSE); - mac_transceiver_info_set_usable(infop, B_FALSE); - } + qede_t *qede = arg; + struct ecore_dev *edev = &qede->edev; + struct ecore_hwfn *hwfn; + struct ecore_ptt *ptt; + uint32_t transceiver_state; + + if (id >= edev->num_hwfns || arg == NULL || infop == NULL) + return (EINVAL); + + hwfn = &edev->hwfns[id]; + ptt = ecore_ptt_acquire(hwfn); + if (ptt == NULL) { + return (EIO); + } + /* + * Use the underlying raw API to get this information. While the + * ecore_phy routines have some ways of getting to this information, it + * ends up writing the raw data as ASCII characters which doesn't help + * us one bit. + */ + transceiver_state = ecore_rd(hwfn, ptt, hwfn->mcp_info->port_addr + + OFFSETOF(struct public_port, transceiver_data)); + transceiver_state = GET_FIELD(transceiver_state, ETH_TRANSCEIVER_STATE); + ecore_ptt_release(hwfn, ptt); + + if ((transceiver_state & ETH_TRANSCEIVER_STATE_PRESENT) != 0) { + mac_transceiver_info_set_present(infop, B_TRUE); + /* + * Based on our testing, the ETH_TRANSCEIVER_STATE_VALID flag is + * not set, so we cannot rely on it. Instead, we have found that + * the ETH_TRANSCEIVER_STATE_UPDATING will be set when we cannot + * use the transceiver. + */ + if ((transceiver_state & ETH_TRANSCEIVER_STATE_UPDATING) != 0) { + mac_transceiver_info_set_usable(infop, B_FALSE); + } else { + mac_transceiver_info_set_usable(infop, B_TRUE); + } + } else { + mac_transceiver_info_set_present(infop, B_FALSE); + mac_transceiver_info_set_usable(infop, B_FALSE); + } - return (0); + return (0); } static int qede_transceiver_read(void *arg, uint_t id, uint_t page, void *buf, size_t nbytes, off_t offset, size_t *nread) { - qede_t *qede = arg; - struct ecore_dev *edev = &qede->edev; - struct ecore_hwfn *hwfn; - uint32_t port, lane; - struct ecore_ptt *ptt; - enum _ecore_status_t ret; - - if (id >= edev->num_hwfns || buf == NULL || nbytes == 0 || nread == NULL || - (page != 0xa0 && page != 0xa2) || offset < 0) - return (EINVAL); - - /* - * Both supported pages have a length of 256 bytes, ensure nothing asks - * us to go beyond that. - */ - if (nbytes > 256 || offset >= 256 || (offset + nbytes > 256)) { - return (EINVAL); - } + qede_t *qede = arg; + struct ecore_dev *edev = &qede->edev; + struct ecore_hwfn *hwfn; + uint32_t port, lane; + struct ecore_ptt *ptt; + enum _ecore_status_t ret; + + if (id >= edev->num_hwfns || buf == NULL || nbytes == 0 || nread == NULL || + (page != 0xa0 && page != 0xa2) || offset < 0) + return (EINVAL); + + /* + * Both supported pages have a length of 256 bytes, ensure nothing asks + * us to go beyond that. + */ + if (nbytes > 256 || offset >= 256 || (offset + nbytes > 256)) { + return (EINVAL); + } - hwfn = &edev->hwfns[id]; - ptt = ecore_ptt_acquire(hwfn); - if (ptt == NULL) { - return (EIO); - } + hwfn = &edev->hwfns[id]; + ptt = ecore_ptt_acquire(hwfn); + if (ptt == NULL) { + return (EIO); + } - ret = ecore_mcp_phy_sfp_read(hwfn, ptt, hwfn->port_id, page, offset, - nbytes, buf); - ecore_ptt_release(hwfn, ptt); - if (ret != ECORE_SUCCESS) { - return (EIO); - } - *nread = nbytes; - return (0); + ret = ecore_mcp_phy_sfp_read(hwfn, ptt, hwfn->port_id, page, offset, + nbytes, buf); + ecore_ptt_release(hwfn, ptt); + if (ret != ECORE_SUCCESS) { + return (EIO); + } + *nread = nbytes; + return (0); } #endif /* ILLUMOS */ + static int qede_mac_stats(void * arg, uint_t stat, @@ -683,16 +699,14 @@ qede_mac_stats(void * arg, qede_rx_ring_t *rx_ring; qede_tx_ring_t *tx_ring; - if ((qede == NULL) || (value == NULL)) - { + if ((qede == NULL) || (value == NULL)) { return EINVAL; } mutex_enter(&qede->gld_lock); - if(qede->qede_state != QEDE_STATE_STARTED) - { + if(qede->qede_state != QEDE_STATE_STARTED) { mutex_exit(&qede->gld_lock); return EAGAIN; } @@ -711,30 +725,31 @@ qede_mac_stats(void * arg, switch (stat) { case MAC_STAT_IFSPEED: - *value = (qede->props.link_speed * 1000000ULL); - break; + *value = (qede->props.link_speed * 1000000ULL); + break; case MAC_STAT_MULTIRCV: - *value = vstats.common.rx_mcast_pkts; - break; + *value = vstats.common.rx_mcast_pkts; + break; case MAC_STAT_BRDCSTRCV: - *value = vstats.common.rx_bcast_pkts; - break; + *value = vstats.common.rx_bcast_pkts; + break; case MAC_STAT_MULTIXMT: - *value = vstats.common.tx_mcast_pkts; - break; + *value = vstats.common.tx_mcast_pkts; + break; case MAC_STAT_BRDCSTXMT: - *value = vstats.common.tx_bcast_pkts; - break; + *value = vstats.common.tx_bcast_pkts; + break; case MAC_STAT_NORCVBUF: - *value = vstats.common.no_buff_discards; - break; + *value = vstats.common.no_buff_discards; + break; case MAC_STAT_NOXMTBUF: - *value = 0; - break; + *value = 0; + break; case MAC_STAT_IERRORS: case ETHER_STAT_MACRCV_ERRORS: *value = vstats.common.mac_filter_discards + - vstats.common.packet_too_big_discard + vstats.common.rx_crc_errors; + vstats.common.packet_too_big_discard + + vstats.common.rx_crc_errors; break; case MAC_STAT_OERRORS: @@ -745,19 +760,27 @@ qede_mac_stats(void * arg, break; case MAC_STAT_RBYTES: - *value = vstats.common.rx_ucast_bytes + vstats.common.rx_mcast_bytes + vstats.common.rx_bcast_bytes; + *value = vstats.common.rx_ucast_bytes + + vstats.common.rx_mcast_bytes + + vstats.common.rx_bcast_bytes; break; case MAC_STAT_IPACKETS: - *value = vstats.common.rx_ucast_pkts + vstats.common.rx_mcast_pkts + vstats.common.rx_bcast_pkts; + *value = vstats.common.rx_ucast_pkts + + vstats.common.rx_mcast_pkts + + vstats.common.rx_bcast_pkts; break; case MAC_STAT_OBYTES: - *value = vstats.common.tx_ucast_bytes + vstats.common.tx_mcast_bytes + vstats.common.tx_bcast_bytes; + *value = vstats.common.tx_ucast_bytes + + vstats.common.tx_mcast_bytes + + vstats.common.tx_bcast_bytes; break; case MAC_STAT_OPACKETS: - *value = vstats.common.tx_ucast_pkts + vstats.common.tx_mcast_pkts + vstats.common.tx_bcast_pkts; + *value = vstats.common.tx_ucast_pkts + + vstats.common.tx_mcast_pkts + + vstats.common.tx_bcast_pkts; break; case ETHER_STAT_ALIGN_ERRORS: @@ -774,13 +797,13 @@ qede_mac_stats(void * arg, case ETHER_STAT_MULTI_COLLISIONS: break; - case ETHER_STAT_DEFER_XMTS: + case ETHER_STAT_DEFER_XMTS: break; case ETHER_STAT_TX_LATE_COLLISIONS: break; - case ETHER_STAT_EX_COLLISIONS: + case ETHER_STAT_EX_COLLISIONS: break; case ETHER_STAT_MACXMT_ERRORS: @@ -805,12 +828,11 @@ qede_mac_stats(void * arg, break; case ETHER_STAT_XCVR_ID: - *value = 0; - break; + *value = 0; + break; case ETHER_STAT_XCVR_INUSE: - switch (qede->props.link_speed) - { + switch (qede->props.link_speed) { default: *value = XCVR_UNDEFINED; } @@ -820,26 +842,18 @@ qede_mac_stats(void * arg, *value = 0; break; #endif - case ETHER_STAT_CAP_100FDX: - *value = 0; - break; - case ETHER_STAT_CAP_100HDX: - *value = 0; - break; - -case ETHER_STAT_CAP_10FDX: - *value = 0; - break; - - + case ETHER_STAT_CAP_100FDX: + *value = 0; + break; + case ETHER_STAT_CAP_100HDX: + *value = 0; + break; case ETHER_STAT_CAP_ASMPAUSE: *value = 1; break; - case ETHER_STAT_CAP_PAUSE: *value = 1; break; - case ETHER_STAT_CAP_AUTONEG: *value = 1; break; @@ -881,83 +895,82 @@ case ETHER_STAT_CAP_10FDX: *value = (qede->props.link_duplex == DUPLEX_FULL) ? LINK_DUPLEX_FULL : LINK_DUPLEX_HALF; break; + /* + * Supported speeds. These indicate what hardware is capable of. + */ + case ETHER_STAT_CAP_1000HDX: + *value = qede->curcfg.supp_capab.param_1000hdx; + break; - /* - * Supported speeds. These indicate what hardware is capable of. - */ - case ETHER_STAT_CAP_1000HDX: - *value = qede->curcfg.supp_capab.param_1000hdx; - break; - - case ETHER_STAT_CAP_1000FDX: - *value = qede->curcfg.supp_capab.param_1000fdx; - break; + case ETHER_STAT_CAP_1000FDX: + *value = qede->curcfg.supp_capab.param_1000fdx; + break; - case ETHER_STAT_CAP_10GFDX: - *value = qede->curcfg.supp_capab.param_10000fdx; - break; + case ETHER_STAT_CAP_10GFDX: + *value = qede->curcfg.supp_capab.param_10000fdx; + break; - case ETHER_STAT_CAP_25GFDX: - *value = qede->curcfg.supp_capab.param_25000fdx; - break; + case ETHER_STAT_CAP_25GFDX: + *value = qede->curcfg.supp_capab.param_25000fdx; + break; - case ETHER_STAT_CAP_40GFDX: - *value = qede->curcfg.supp_capab.param_40000fdx; - break; + case ETHER_STAT_CAP_40GFDX: + *value = qede->curcfg.supp_capab.param_40000fdx; + break; - case ETHER_STAT_CAP_50GFDX: - *value = qede->curcfg.supp_capab.param_50000fdx; - break; + case ETHER_STAT_CAP_50GFDX: + *value = qede->curcfg.supp_capab.param_50000fdx; + break; - case ETHER_STAT_CAP_100GFDX: - *value = qede->curcfg.supp_capab.param_100000fdx; - break; + case ETHER_STAT_CAP_100GFDX: + *value = qede->curcfg.supp_capab.param_100000fdx; + break; - /* - * Advertised speeds. These indicate what hardware is currently sending. - */ - case ETHER_STAT_ADV_CAP_1000HDX: - *value = qede->curcfg.adv_capab.param_1000hdx; - break; + /* + * Advertised speeds. These indicate what hardware is currently sending. + */ + case ETHER_STAT_ADV_CAP_1000HDX: + *value = qede->curcfg.adv_capab.param_1000hdx; + break; - case ETHER_STAT_ADV_CAP_1000FDX: - *value = qede->curcfg.adv_capab.param_1000fdx; - break; + case ETHER_STAT_ADV_CAP_1000FDX: + *value = qede->curcfg.adv_capab.param_1000fdx; + break; - case ETHER_STAT_ADV_CAP_10GFDX: - *value = qede->curcfg.adv_capab.param_10000fdx; - break; + case ETHER_STAT_ADV_CAP_10GFDX: + *value = qede->curcfg.adv_capab.param_10000fdx; + break; - case ETHER_STAT_ADV_CAP_25GFDX: - *value = qede->curcfg.adv_capab.param_25000fdx; - break; + case ETHER_STAT_ADV_CAP_25GFDX: + *value = qede->curcfg.adv_capab.param_25000fdx; + break; - case ETHER_STAT_ADV_CAP_40GFDX: - *value = qede->curcfg.adv_capab.param_40000fdx; - break; + case ETHER_STAT_ADV_CAP_40GFDX: + *value = qede->curcfg.adv_capab.param_40000fdx; + break; - case ETHER_STAT_ADV_CAP_50GFDX: - *value = qede->curcfg.adv_capab.param_50000fdx; - break; + case ETHER_STAT_ADV_CAP_50GFDX: + *value = qede->curcfg.adv_capab.param_50000fdx; + break; - case ETHER_STAT_ADV_CAP_100GFDX: - *value = qede->curcfg.adv_capab.param_100000fdx; - break; + case ETHER_STAT_ADV_CAP_100GFDX: + *value = qede->curcfg.adv_capab.param_100000fdx; + break; default: rc = ENOTSUP; } mutex_exit(&qede->gld_lock); - return rc; + return (rc); } /* (flag) TRUE = on, FALSE = off */ static int -qede_mac_promiscuous(void * arg, - boolean_t on) +qede_mac_promiscuous(void *arg, + boolean_t on) { - qede_t * qede = (qede_t *)arg; + qede_t *qede = (qede_t *)arg; qede_print("!%s(%d): called", __func__,qede->instance); int ret = DDI_SUCCESS; enum qede_filter_rx_mode_type mode; @@ -1004,7 +1017,8 @@ int qede_set_rx_mac_mcast(qede_t *qede, enum ecore_filter_opcode opcode, } - return ecore_filter_mcast_cmd(&qede->edev, &cmd, ECORE_SPQ_MODE_CB, NULL); + return (ecore_filter_mcast_cmd(&qede->edev, &cmd, + ECORE_SPQ_MODE_CB, NULL)); } @@ -1017,18 +1031,22 @@ qede_set_filter_rx_mode(qede_t * qede, enum qede_filter_rx_mode_type type) flg.update_rx_mode_config = 1; flg.update_tx_mode_config = 1; - flg.rx_accept_filter = ECORE_ACCEPT_UCAST_MATCHED | ECORE_ACCEPT_MCAST_MATCHED | ECORE_ACCEPT_BCAST; - flg.tx_accept_filter = ECORE_ACCEPT_UCAST_MATCHED | ECORE_ACCEPT_MCAST_MATCHED | ECORE_ACCEPT_BCAST; + flg.rx_accept_filter = ECORE_ACCEPT_UCAST_MATCHED | + ECORE_ACCEPT_MCAST_MATCHED | ECORE_ACCEPT_BCAST; + flg.tx_accept_filter = ECORE_ACCEPT_UCAST_MATCHED | + ECORE_ACCEPT_MCAST_MATCHED | ECORE_ACCEPT_BCAST; if (type == QEDE_FILTER_RX_MODE_PROMISC) - flg.rx_accept_filter |= ECORE_ACCEPT_UCAST_UNMATCHED | ECORE_ACCEPT_MCAST_UNMATCHED; + flg.rx_accept_filter |= ECORE_ACCEPT_UCAST_UNMATCHED | + ECORE_ACCEPT_MCAST_UNMATCHED; else if (type == QEDE_FILTER_RX_MODE_MULTI_PROMISC) flg.rx_accept_filter |= ECORE_ACCEPT_MCAST_UNMATCHED; - qede_info(qede, "rx_mode rx_filter=0x%x tx_filter=0x%x type=0x%x\n", flg.rx_accept_filter, flg.tx_accept_filter, type); - return ecore_filter_accept_cmd(&qede->edev, 0, flg, + qede_info(qede, "rx_mode rx_filter=0x%x tx_filter=0x%x type=0x%x\n", + flg.rx_accept_filter, flg.tx_accept_filter, type); + return (ecore_filter_accept_cmd(&qede->edev, 0, flg, 0, /* update_accept_any_vlan */ 0, /* accept_any_vlan */ - ECORE_SPQ_MODE_CB, NULL); + ECORE_SPQ_MODE_CB, NULL)); } int @@ -1043,25 +1061,25 @@ qede_multicast(qede_t *qede, boolean_t flag, const uint8_t *ptr_mcaddr) boolean_t mcmac_exists = B_FALSE; enum qede_filter_rx_mode_type mode; - if (!ptr_mcaddr) + if (!ptr_mcaddr) { cmn_err(CE_NOTE, "Removing all multicast"); - else - cmn_err(CE_NOTE,"qede=%p %s multicast: %02x:%02x:%02x:%02x:%02x:%02x", - qede, (flag) ? "Adding" : "Removing", ptr_mcaddr[0], - ptr_mcaddr[1],ptr_mcaddr[2],ptr_mcaddr[3],ptr_mcaddr[4], - ptr_mcaddr[5]); - + } else { + cmn_err(CE_NOTE, + "qede=%p %s multicast: %02x:%02x:%02x:%02x:%02x:%02x", + qede, (flag) ? "Adding" : "Removing", ptr_mcaddr[0], + ptr_mcaddr[1],ptr_mcaddr[2],ptr_mcaddr[3],ptr_mcaddr[4], + ptr_mcaddr[5]); + } - if (flag && (ptr_mcaddr == NULL)) - { + if (flag && (ptr_mcaddr == NULL)) { cmn_err(CE_WARN, "ERROR: Multicast address not specified"); return EINVAL; } /* exceeds addition of mcaddr above limit */ - if( flag && (qede->mc_cnt >= MAX_MC_SOFT_LIMIT) ) { + if (flag && (qede->mc_cnt >= MAX_MC_SOFT_LIMIT)) { qede_info(qede, "Cannot add more than MAX_MC_SOFT_LIMIT"); return ENOENT; } @@ -1069,8 +1087,7 @@ qede_multicast(qede_t *qede, boolean_t flag, const uint8_t *ptr_mcaddr) size = MAX_MC_SOFT_LIMIT * ETH_ALLEN; mc_macs = kmem_zalloc(size, KM_NOSLEEP); - if (!mc_macs) - { + if (!mc_macs) { cmn_err(CE_WARN, "ERROR: Failed to allocate for mc_macs"); return EINVAL; } @@ -1078,67 +1095,76 @@ qede_multicast(qede_t *qede, boolean_t flag, const uint8_t *ptr_mcaddr) tmpmc = mc_macs; /* remove all multicast - as flag not set and mcaddr not specified*/ - if (!flag && (ptr_mcaddr == NULL)) - { - QEDE_LIST_FOR_EACH_ENTRY(ptr_entry, &qede->mclist.head, qede_mcast_list_entry_t, mclist_entry) + if (!flag && (ptr_mcaddr == NULL)) { + QEDE_LIST_FOR_EACH_ENTRY(ptr_entry, + &qede->mclist.head, qede_mcast_list_entry_t, mclist_entry) { - if(ptr_entry != NULL) - { - QEDE_LIST_REMOVE(&ptr_entry->mclist_entry, &qede->mclist.head); - kmem_free(ptr_entry, sizeof(qede_mcast_list_entry_t) + ETH_ALLEN); + if (ptr_entry != NULL) { + QEDE_LIST_REMOVE(&ptr_entry->mclist_entry, + &qede->mclist.head); + kmem_free(ptr_entry, + sizeof (qede_mcast_list_entry_t) + ETH_ALLEN); } } - ret = qede_set_rx_mac_mcast(qede, ECORE_FILTER_REMOVE, mc_macs, 1); + ret = qede_set_rx_mac_mcast(qede, + ECORE_FILTER_REMOVE, mc_macs, 1); qede->mc_cnt = 0; goto exit; } - QEDE_LIST_FOR_EACH_ENTRY(ptr_entry, &qede->mclist.head, qede_mcast_list_entry_t, mclist_entry) + QEDE_LIST_FOR_EACH_ENTRY(ptr_entry, + &qede->mclist.head, qede_mcast_list_entry_t, mclist_entry) { - if(ptr_entry != NULL && IS_ETH_ADDRESS_EQUAL(ptr_mcaddr, ptr_entry->mac) ) { + if ((ptr_entry != NULL) && + IS_ETH_ADDRESS_EQUAL(ptr_mcaddr, ptr_entry->mac)) { mcmac_exists = B_TRUE; break; } } - if( flag && mcmac_exists) { - /*qede_info(qede, "mcaddr already added\n");*/ + if (flag && mcmac_exists) { ret = DDI_SUCCESS; goto exit; - } else if ( !flag && !mcmac_exists) { - /*qede_info(qede, "mcaddr is not there mc_cnt = %d\n", qede->mc_cnt);*/ + } else if (!flag && !mcmac_exists) { ret = DDI_SUCCESS; goto exit; } - if (flag) - { - ptr_entry = kmem_zalloc((sizeof(qede_mcast_list_entry_t) + ETH_ALLEN), KM_NOSLEEP); - ptr_entry->mac = (uint8_t *)ptr_entry + sizeof(qede_mcast_list_entry_t); + if (flag) { + ptr_entry = kmem_zalloc((sizeof (qede_mcast_list_entry_t) + + ETH_ALLEN), KM_NOSLEEP); + ptr_entry->mac = (uint8_t *)ptr_entry + + sizeof (qede_mcast_list_entry_t); COPY_ETH_ADDRESS(ptr_mcaddr, ptr_entry->mac); QEDE_LIST_ADD(&ptr_entry->mclist_entry, &qede->mclist.head); } else { QEDE_LIST_REMOVE(&ptr_entry->mclist_entry, &qede->mclist.head); - kmem_free(ptr_entry, sizeof(qede_mcast_list_entry_t) + ETH_ALLEN); + kmem_free(ptr_entry, sizeof(qede_mcast_list_entry_t) + + ETH_ALLEN); } mc_cnt = 0; - QEDE_LIST_FOR_EACH_ENTRY(ptr_entry, &qede->mclist.head, qede_mcast_list_entry_t, mclist_entry) { + QEDE_LIST_FOR_EACH_ENTRY(ptr_entry, &qede->mclist.head, + qede_mcast_list_entry_t, mclist_entry) { COPY_ETH_ADDRESS(ptr_entry->mac, tmpmc); tmpmc += ETH_ALLEN; mc_cnt++; } qede->mc_cnt = mc_cnt; - if(mc_cnt <=64) { - ret = qede_set_rx_mac_mcast(qede, ECORE_FILTER_ADD, (unsigned char *)mc_macs, mc_cnt); - if ((qede->params.multi_promisc_fl == B_TRUE) && (qede->params.promisc_fl == B_FALSE)) { + if (mc_cnt <=64) { + ret = qede_set_rx_mac_mcast(qede, ECORE_FILTER_ADD, + (unsigned char *)mc_macs, mc_cnt); + if ((qede->params.multi_promisc_fl == B_TRUE) && + (qede->params.promisc_fl == B_FALSE)) { mode = QEDE_FILTER_RX_MODE_REGULAR; ret = qede_set_filter_rx_mode(qede, mode); } qede->params.multi_promisc_fl = B_FALSE; } else { - if ((qede->params.multi_promisc_fl == B_FALSE) && (qede->params.promisc_fl = B_FALSE)) { - ret = qede_set_filter_rx_mode(qede, QEDE_FILTER_RX_MODE_MULTI_PROMISC); + if ((qede->params.multi_promisc_fl == B_FALSE) && + (qede->params.promisc_fl = B_FALSE)) { + ret = qede_set_filter_rx_mode(qede, + QEDE_FILTER_RX_MODE_MULTI_PROMISC); } qede->params.multi_promisc_fl = B_TRUE; qede_info(qede, "mode is MULTI_PROMISC"); @@ -1146,7 +1172,7 @@ qede_multicast(qede_t *qede, boolean_t flag, const uint8_t *ptr_mcaddr) exit: kmem_free(mc_macs, size); qede_info(qede, "multicast ret %d mc_cnt %d\n", ret, qede->mc_cnt); -return ret; +return (ret); } /* @@ -1155,19 +1181,18 @@ return ret; * (flag) TRUE = add, FALSE = remove */ static int -qede_mac_multicast(void * arg, - boolean_t flag, - const uint8_t * mcast_addr) +qede_mac_multicast(void *arg, + boolean_t flag, + const uint8_t * mcast_addr) { - qede_t * qede = (qede_t *)arg; - int ret = DDI_SUCCESS; + qede_t *qede = (qede_t *)arg; + int ret = DDI_SUCCESS; mutex_enter(&qede->gld_lock); - if(qede->qede_state != QEDE_STATE_STARTED) - { + if(qede->qede_state != QEDE_STATE_STARTED) { mutex_exit(&qede->gld_lock); - return EAGAIN; + return (EAGAIN); } ret = qede_multicast(qede, flag, mcast_addr); @@ -1180,44 +1205,49 @@ qede_clear_filters(qede_t *qede) { int ret = 0; int i; - if((qede->params.promisc_fl == B_TRUE) || (qede->params.multi_promisc_fl == B_TRUE)) { - ret = qede_set_filter_rx_mode(qede, QEDE_FILTER_RX_MODE_REGULAR); - if(ret) - qede_info(qede, "qede_clear_filters failed to set rx_mode"); + if ((qede->params.promisc_fl == B_TRUE) || + (qede->params.multi_promisc_fl == B_TRUE)) { + ret = qede_set_filter_rx_mode(qede, + QEDE_FILTER_RX_MODE_REGULAR); + if (ret) { + qede_info(qede, + "qede_clear_filters failed to set rx_mode"); + } } for (i=0; i < qede->ucst_total; i++) { - if(qede->ucst_mac[i].set) { - qede_rem_macaddr(qede, qede->ucst_mac[i].mac_addr.ether_addr_octet); + if (qede->ucst_mac[i].set) { + qede_rem_macaddr(qede, + qede->ucst_mac[i].mac_addr.ether_addr_octet); } } qede_multicast(qede, B_FALSE, NULL); - return ret; + return (ret); } -#ifdef NO_CROSSBOW +#ifdef NO_CROSSBOW static int -qede_mac_unicast(void * arg, - const uint8_t * mac_addr) +qede_mac_unicast(void *arg, + const uint8_t * mac_addr) { - qede_t * qede = (qede_t *)arg; + qede_t *qede = (qede_t *)arg; return 0; } static mblk_t * -qede_mac_tx(void * arg, - mblk_t * mblk) +qede_mac_tx(void *arg, + mblk_t * mblk) { - qede_t * qede = (qede_t *)arg; + qede_t *qede = (qede_t *)arg; qede_fastpath_t *fp = &qede->fp_array[0]; mblk = qede_ring_tx((void *)fp, mblk); - return mblk; + return (mblk); } -#endif /* NO_CROSSBOW */ +#endif /* NO_CROSSBOW */ static lb_property_t loopmodes[] = { @@ -1244,57 +1274,57 @@ qede_set_loopback_mode(qede_t *qede, uint32_t mode) ptt = ecore_ptt_acquire(hwfn); switch(mode) { - default: - qede_info(qede, "unknown loopback mode !!"); - ecore_ptt_release(hwfn, ptt); - return IOC_INVAL; + default: + qede_info(qede, "unknown loopback mode !!"); + ecore_ptt_release(hwfn, ptt); + return IOC_INVAL; - case QEDE_LOOP_NONE: - ecore_mcp_set_link(hwfn, ptt, 0); + case QEDE_LOOP_NONE: + ecore_mcp_set_link(hwfn, ptt, 0); - while(qede->params.link_state && i < 5000){ - OSAL_MSLEEP(1); - i++; - } - i = 0; + while (qede->params.link_state && i < 5000) { + OSAL_MSLEEP(1); + i++; + } + i = 0; - link_params->loopback_mode = ETH_LOOPBACK_NONE; - qede->loop_back_mode = QEDE_LOOP_NONE; - ret = ecore_mcp_set_link(hwfn, ptt, 1); - ecore_ptt_release(hwfn, ptt); + link_params->loopback_mode = ETH_LOOPBACK_NONE; + qede->loop_back_mode = QEDE_LOOP_NONE; + ret = ecore_mcp_set_link(hwfn, ptt, 1); + ecore_ptt_release(hwfn, ptt); - while(!qede->params.link_state && i < 5000){ - OSAL_MSLEEP(1); - i++; - } - return IOC_REPLY; + while (!qede->params.link_state && i < 5000) { + OSAL_MSLEEP(1); + i++; + } + return IOC_REPLY; - case QEDE_LOOP_INTERNAL: - qede_print("!%s(%d) : loopback mode (INTERNAL) is set!", - __func__, qede->instance); - ecore_mcp_set_link(hwfn, ptt, 0); + case QEDE_LOOP_INTERNAL: + qede_print("!%s(%d) : loopback mode (INTERNAL) is set!", + __func__, qede->instance); + ecore_mcp_set_link(hwfn, ptt, 0); - while(qede->params.link_state && i < 5000){ - OSAL_MSLEEP(1); - i++; - } - i = 0; - link_params->loopback_mode = ETH_LOOPBACK_INT_PHY; - qede->loop_back_mode = QEDE_LOOP_INTERNAL; - ret = ecore_mcp_set_link(hwfn, ptt, 1); - ecore_ptt_release(hwfn, ptt); - - while(!qede->params.link_state && i < 5000){ - OSAL_MSLEEP(1); - i++; - } - return IOC_REPLY; + while(qede->params.link_state && i < 5000) { + OSAL_MSLEEP(1); + i++; + } + i = 0; + link_params->loopback_mode = ETH_LOOPBACK_INT_PHY; + qede->loop_back_mode = QEDE_LOOP_INTERNAL; + ret = ecore_mcp_set_link(hwfn, ptt, 1); + ecore_ptt_release(hwfn, ptt); - case QEDE_LOOP_EXTERNAL: - qede_print("!%s(%d) : External loopback mode is not supported", - __func__, qede->instance); - ecore_ptt_release(hwfn, ptt); - return IOC_INVAL; + while(!qede->params.link_state && i < 5000) { + OSAL_MSLEEP(1); + i++; + } + return IOC_REPLY; + + case QEDE_LOOP_EXTERNAL: + qede_print("!%s(%d) : External loopback mode is not supported", + __func__, qede->instance); + ecore_ptt_release(hwfn, ptt); + return IOC_INVAL; } } @@ -1308,25 +1338,24 @@ qede_ioctl_pcicfg_rd(qede_t *qede, u32 addr, void *data, ddi_acc_handle_t pci_cfg_handle = qede->pci_cfg_handle; qede_ioctl_data_t * data1 = (qede_ioctl_data_t *) data; -#if 1 cap_offset = pci_config_get8(pci_cfg_handle, PCI_CONF_CAP_PTR); while (cap_offset != 0) { - /* Check for an invalid PCI read. */ - if (cap_offset == PCI_EINVAL8) { - return DDI_FAILURE; - } + /* Check for an invalid PCI read. */ + if (cap_offset == PCI_EINVAL8) { + return DDI_FAILURE; + } cap_id = pci_config_get8(pci_cfg_handle, cap_offset); if (cap_id == PCI_CAP_ID_PCI_E) { /* PCIe expr capab struct found */ break; } else { - next_cap = pci_config_get8(pci_cfg_handle, cap_offset + 1); + next_cap = pci_config_get8(pci_cfg_handle, + cap_offset + 1); cap_offset = next_cap; } } -#endif - switch (len){ + switch (len) { case 1: ret = pci_config_get8(qede->pci_cfg_handle, addr); (void) memcpy(data, &ret, sizeof(uint8_t)); @@ -1341,9 +1370,9 @@ qede_ioctl_pcicfg_rd(qede_t *qede, u32 addr, void *data, break; default: cmn_err(CE_WARN, "bad length for pci config read\n"); - return 1; + return (1); } - return 0; + return (0); } static int @@ -1362,7 +1391,8 @@ qede_ioctl_pcicfg_wr(qede_t *qede, u32 addr, void *data, /* PCIe expr capab struct found */ break; } else { - next_cap = pci_config_get8(pci_cfg_handle, cap_offset + 1); + next_cap = pci_config_get8(pci_cfg_handle, + cap_offset + 1); cap_offset = next_cap; } } @@ -1385,9 +1415,9 @@ qede_ioctl_pcicfg_wr(qede_t *qede, u32 addr, void *data, break; default: - return 1; + return (1); } - return 0; + return (0); } static int @@ -1421,17 +1451,18 @@ qede_ioctl_rd_wr_reg(qede_t *qede, void *data) break; default: - cmn_err(CE_WARN, "wrong command in register read/write from application\n"); + cmn_err(CE_WARN, + "wrong command in register read/write from application\n"); break; } - return ret; + return (ret); } static int qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp) { - //qede_ioctl_data_t *data1 = (qede_ioctl_data_t *)(mp->b_cont->b_rptr), *data2; - qede_nvram_data_t *data1 = (qede_nvram_data_t *)(mp->b_cont->b_rptr), *data2, *next_data; + qede_nvram_data_t *data1 = (qede_nvram_data_t *)(mp->b_cont->b_rptr); + qede_nvram_data_t *data2, *next_data; struct ecore_dev *edev = &qede->edev; uint32_t ret = 0, hdr_size = 24, bytes_to_copy, copy_len = 0; uint32_t copy_len1 = 0; @@ -1446,10 +1477,10 @@ qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp) switch(cmd) { case QEDE_NVRAM_CMD_READ: buf = kmem_zalloc(size, GFP_KERNEL); - //buf = OSAL_ZALLOC(edev, GFP_KERNEL, size); if(buf == NULL) { - cmn_err(CE_WARN, "memory allocation failed in nvram read ioctl\n"); - return DDI_FAILURE; + cmn_err(CE_WARN, "memory allocation failed" + " in nvram read ioctl\n"); + return (DDI_FAILURE); } ret = ecore_mcp_nvm_read(edev, addr, buf, data1->size); @@ -1475,7 +1506,8 @@ qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp) } data2 = (qede_nvram_data_t *)mp1->b_rptr; if (copy_len > bytes_to_copy) { - (void) memcpy(data2->uabc, tmp_buf, bytes_to_copy); + (void) memcpy(data2->uabc, tmp_buf, + bytes_to_copy); kmem_free(buf, size); //OSAL_FREE(edev, buf); break; @@ -1505,11 +1537,13 @@ qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp) //buf = qede->reserved_buf; qede->nvm_buf_size = data1->size; if(buf == NULL) { - cmn_err(CE_WARN, "memory allocation failed in START_NVM_WRITE\n"); + cmn_err(CE_WARN, + "memory allocation failed in START_NVM_WRITE\n"); return DDI_FAILURE; } qede->nvm_buf_start = buf; - cmn_err(CE_NOTE, "buf = %p, size = %x\n", qede->nvm_buf_start, size); + cmn_err(CE_NOTE, + "buf = %p, size = %x\n", qede->nvm_buf_start, size); qede->nvm_buf = buf; qede->copy_len = 0; //tmp_buf = buf + addr; @@ -1522,15 +1556,19 @@ qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp) if(copy_len > buf_size) { if (buf_size < qede->nvm_buf_size) { (void) memcpy(tmp_buf, data1->uabc, buf_size); - qede->copy_len = qede->copy_len + buf_size; + qede->copy_len = qede->copy_len + + buf_size; } else { - (void) memcpy(tmp_buf, data1->uabc, qede->nvm_buf_size); - qede->copy_len = qede->copy_len + qede->nvm_buf_size; + (void) memcpy(tmp_buf, + data1->uabc, qede->nvm_buf_size); + qede->copy_len = + qede->copy_len + qede->nvm_buf_size; } tmp_buf = tmp_buf + buf_size; qede->nvm_buf = tmp_buf; //qede->copy_len = qede->copy_len + buf_size; - cmn_err(CE_NOTE, "buf_size from app = %x\n", copy_len); + cmn_err(CE_NOTE, + "buf_size from app = %x\n", copy_len); ret = 0; break; } @@ -1548,12 +1586,15 @@ qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp) } next_data = (qede_nvram_data_t *) mp1->b_rptr; if (copy_len > bytes_to_copy){ - (void) memcpy(tmp_buf, next_data->uabc, bytes_to_copy); - qede->copy_len = qede->copy_len + bytes_to_copy; + (void) memcpy(tmp_buf, next_data->uabc, + bytes_to_copy); + qede->copy_len = qede->copy_len + + bytes_to_copy; ret = 0; break; } - (void) memcpy(tmp_buf, next_data->uabc, copy_len); + (void) memcpy(tmp_buf, next_data->uabc, + copy_len); qede->copy_len = qede->copy_len + copy_len; tmp_buf = tmp_buf + copy_len; copy_len = copy_len1 + copy_len; @@ -1571,7 +1612,8 @@ qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp) case READ_BUF: tmp_buf = (uint8_t *)qede->nvm_buf_start; for(i = 0; i < size ; i++){ - cmn_err(CE_NOTE, "buff (%d) : %d\n", i, *tmp_buf); + cmn_err(CE_NOTE, + "buff (%d) : %d\n", i, *tmp_buf); tmp_buf ++; } ret = 0; @@ -1612,10 +1654,11 @@ qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp) break; default: - cmn_err(CE_WARN, "wrong command in NVRAM read/write from application\n"); + cmn_err(CE_WARN, + "wrong command in NVRAM read/write from application\n"); break; } - return DDI_SUCCESS; + return (DDI_SUCCESS); } static int @@ -1634,45 +1677,53 @@ qede_get_func_info(qede_t *qede, void *data) if(hwfn == NULL){ cmn_err(CE_WARN, "(%s) : cannot acquire hwfn\n", __func__); - return DDI_FAILURE; + return (DDI_FAILURE); } memcpy(¶ms, &hwfn->mcp_info->link_input, sizeof(params)); memcpy(&link, &hwfn->mcp_info->link_output, sizeof(link)); - if(link.link_up) + if(link.link_up) { link_op.link_up = true; + } link_op.supported_caps = SUPPORTED_FIBRE; - if(params.speed.autoneg) + if(params.speed.autoneg) { link_op.supported_caps |= SUPPORTED_Autoneg; + } if(params.pause.autoneg || - (params.pause.forced_rx && params.pause.forced_tx)) + (params.pause.forced_rx && params.pause.forced_tx)) { link_op.supported_caps |= SUPPORTED_Asym_Pause; + } if (params.pause.autoneg || params.pause.forced_rx || - params.pause.forced_tx) + params.pause.forced_tx) { link_op.supported_caps |= SUPPORTED_Pause; + } if (params.speed.advertised_speeds & - NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_1G) - link_op.supported_caps |= SUPPORTED_1000baseT_Half | - SUPPORTED_1000baseT_Full; + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_1G) { + link_op.supported_caps |= SUPPORTED_1000baseT_Half | + SUPPORTED_1000baseT_Full; + } if (params.speed.advertised_speeds & - NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_10G) + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_10G) { link_op.supported_caps |= SUPPORTED_10000baseKR_Full; + } if (params.speed.advertised_speeds & - NVM_CFG1_PORT_DRV_LINK_SPEED_40G) + NVM_CFG1_PORT_DRV_LINK_SPEED_40G) { link_op.supported_caps |= SUPPORTED_40000baseLR4_Full; + } link_op.advertised_caps = link_op.supported_caps; - if(link.link_up) + if(link.link_up) { link_op.speed = link.speed; - else + } else { link_op.speed = 0; + } link_op.duplex = DUPLEX_FULL; link_op.port = PORT_FIBRE; @@ -1681,34 +1732,42 @@ qede_get_func_info(qede_t *qede, void *data) /* Link partner capabilities */ if (link.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_1G_HD) + ECORE_LINK_PARTNER_SPEED_1G_HD) { link_op.lp_caps |= SUPPORTED_1000baseT_Half; + } if (link.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_1G_FD) + ECORE_LINK_PARTNER_SPEED_1G_FD) { link_op.lp_caps |= SUPPORTED_1000baseT_Full; + } if (link.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_10G) + ECORE_LINK_PARTNER_SPEED_10G) { link_op.lp_caps |= SUPPORTED_10000baseKR_Full; + } if (link.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_20G) + ECORE_LINK_PARTNER_SPEED_20G) { link_op.lp_caps |= SUPPORTED_20000baseKR2_Full; + } if (link.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_40G) + ECORE_LINK_PARTNER_SPEED_40G) { link_op.lp_caps |= SUPPORTED_40000baseLR4_Full; + } - if (link.an_complete) + if (link.an_complete) { link_op.lp_caps |= SUPPORTED_Autoneg; + } - if (link.partner_adv_pause) + if (link.partner_adv_pause) { link_op.lp_caps |= SUPPORTED_Pause; + } if (link.partner_adv_pause == ECORE_LINK_PARTNER_ASYMMETRIC_PAUSE || - link.partner_adv_pause == ECORE_LINK_PARTNER_BOTH_PAUSE) + link.partner_adv_pause == ECORE_LINK_PARTNER_BOTH_PAUSE) { link_op.lp_caps |= SUPPORTED_Asym_Pause; + } func_info.supported = link_op.supported_caps; func_info.advertising = link_op.advertised_caps; @@ -1719,7 +1778,7 @@ qede_get_func_info(qede_t *qede, void *data) (void) memcpy(data1->uabc, &func_info, sizeof(qede_func_info_t)); - return 0; + return (0); } static int @@ -1746,26 +1805,31 @@ qede_do_ioctl(qede_t *qede, queue_t *q, mblk_t *mp) off = up_data->off; size = up_data->size; - switch(cmd) { + switch (cmd) { case QEDE_DRV_INFO: hwfn = &edev->hwfns[0]; ptt = ecore_ptt_acquire(hwfn); snprintf(driver_info.drv_name, MAX_QEDE_NAME_LEN, "%s", "qede"); - //snprintf(driver_info.drv_name, MAX_QEDE_NAME_LEN, "%s", qede->name); - snprintf(driver_info.drv_version, QEDE_STR_SIZE, "v:%s", qede->version); - snprintf(driver_info.mfw_version, QEDE_STR_SIZE, "%s", qede->versionMFW); - snprintf(driver_info.stormfw_version, QEDE_STR_SIZE, "%s", qede->versionFW); - snprintf(driver_info.bus_info, QEDE_STR_SIZE, "%s", qede->bus_dev_func); + snprintf(driver_info.drv_version, QEDE_STR_SIZE, + "v:%s", qede->version); + snprintf(driver_info.mfw_version, QEDE_STR_SIZE, + "%s", qede->versionMFW); + snprintf(driver_info.stormfw_version, QEDE_STR_SIZE, + "%s", qede->versionFW); + snprintf(driver_info.bus_info, QEDE_STR_SIZE, + "%s", qede->bus_dev_func); - /* calling ecore_mcp_nvm_rd_cmd to find the flash length, i + /* + * calling ecore_mcp_nvm_rd_cmd to find the flash length, i * 0x08 is equivalent of NVM_TYPE_MFW_TRACE1 */ ecore_mcp_get_flash_size(hwfn, ptt, &flash_size); driver_info.eeprom_dump_len = flash_size; - (void) memcpy(up_data->uabc, &driver_info, sizeof(qede_driver_info_t)); - up_data->size = sizeof(qede_driver_info_t); + (void) memcpy(up_data->uabc, &driver_info, + sizeof (qede_driver_info_t)); + up_data->size = sizeof (qede_driver_info_t); ecore_ptt_release(hwfn, ptt); break; @@ -1806,7 +1870,7 @@ qede_do_ioctl(qede_t *qede, queue_t *q, mblk_t *mp) //} miocack (q, mp, (sizeof(qede_ioctl_data_t)), ret); //miocack (q, mp, 0, ret); - return IOC_REPLY; + return (IOC_REPLY); } static void @@ -1836,51 +1900,52 @@ qede_loopback_ioctl(qede_t *qede, queue_t *wq, mblk_t *mp, /* * Validate format of ioctl */ - if(mp->b_cont == NULL) + if(mp->b_cont == NULL) { return IOC_INVAL; + } cmd = iocp->ioc_cmd; switch(cmd) { - default: - qede_print("!%s(%d): unknown ioctl command %x\n", - __func__, qede->instance, cmd); + default: + qede_print("!%s(%d): unknown ioctl command %x\n", + __func__, qede->instance, cmd); + return IOC_INVAL; + case LB_GET_INFO_SIZE: + if (iocp->ioc_count != sizeof(lb_info_sz_t)) { + qede_info(qede, "error: ioc_count %d, sizeof %d", + iocp->ioc_count, sizeof(lb_info_sz_t)); return IOC_INVAL; - case LB_GET_INFO_SIZE: - if (iocp->ioc_count != sizeof(lb_info_sz_t)) { - qede_info(qede, "error: ioc_count %d, sizeof %d", - iocp->ioc_count, sizeof(lb_info_sz_t)); - return IOC_INVAL; - } - lb_info_size = (void *)mp->b_cont->b_rptr; - *lb_info_size = sizeof(loopmodes); - return IOC_REPLY; - case LB_GET_INFO: - if (iocp->ioc_count != sizeof (loopmodes)) { - qede_info(qede, "error: iocp->ioc_count %d, sizepof %d", - iocp->ioc_count, sizeof (loopmodes)); - return (IOC_INVAL); - } - lb_prop = (void *)mp->b_cont->b_rptr; - bcopy(loopmodes, lb_prop, sizeof (loopmodes)); - return IOC_REPLY; - case LB_GET_MODE: - if (iocp->ioc_count != sizeof (uint32_t)) { - qede_info(qede, "iocp->ioc_count %d, sizeof : %d\n", - iocp->ioc_count, sizeof (uint32_t)); - return (IOC_INVAL); - } - lb_mode = (void *)mp->b_cont->b_rptr; - *lb_mode = qede->loop_back_mode; - return IOC_REPLY; - case LB_SET_MODE: - if (iocp->ioc_count != sizeof (uint32_t)) { - qede_info(qede, "iocp->ioc_count %d, sizeof : %d\n", - iocp->ioc_count, sizeof (uint32_t)); - return (IOC_INVAL); - } - lb_mode = (void *)mp->b_cont->b_rptr; - return (qede_set_loopback_mode(qede,*lb_mode)); + } + lb_info_size = (void *)mp->b_cont->b_rptr; + *lb_info_size = sizeof(loopmodes); + return IOC_REPLY; + case LB_GET_INFO: + if (iocp->ioc_count != sizeof (loopmodes)) { + qede_info(qede, "error: iocp->ioc_count %d, sizepof %d", + iocp->ioc_count, sizeof (loopmodes)); + return (IOC_INVAL); + } + lb_prop = (void *)mp->b_cont->b_rptr; + bcopy(loopmodes, lb_prop, sizeof (loopmodes)); + return IOC_REPLY; + case LB_GET_MODE: + if (iocp->ioc_count != sizeof (uint32_t)) { + qede_info(qede, "iocp->ioc_count %d, sizeof : %d\n", + iocp->ioc_count, sizeof (uint32_t)); + return (IOC_INVAL); + } + lb_mode = (void *)mp->b_cont->b_rptr; + *lb_mode = qede->loop_back_mode; + return IOC_REPLY; + case LB_SET_MODE: + if (iocp->ioc_count != sizeof (uint32_t)) { + qede_info(qede, "iocp->ioc_count %d, sizeof : %d\n", + iocp->ioc_count, sizeof (uint32_t)); + return (IOC_INVAL); + } + lb_mode = (void *)mp->b_cont->b_rptr; + return (qede_set_loopback_mode(qede,*lb_mode)); } } @@ -1900,7 +1965,7 @@ qede_mac_ioctl(void * arg, mutex_enter(&qede->drv_lock); if ((qede->qede_state == QEDE_STATE_SUSPENDING) || - (qede->qede_state == QEDE_STATE_SUSPENDED)){ + (qede->qede_state == QEDE_STATE_SUSPENDED)) { mutex_exit(&qede->drv_lock); miocnak(wq, mp, 0, EINVAL); return; @@ -2010,12 +2075,14 @@ qede_mac_get_capability(void *arg, ret = B_FALSE; break; } - - /* - * Hardware does not support ICMPv6 checksumming, but - * HCKSUM_INET_FULL_V4/6 only applies for UDP and TCP. - */ - *tx_flags = HCKSUM_INET_FULL_V4 | HCKSUM_INET_FULL_V6 | + /* + * Hardware does not support ICMPv6 checksumming. Right now the + * GLDv3 doesn't provide us a way to specify that we don't + * support that. As such, we cannot indicate + * HCKSUM_INET_FULL_V6. + */ + + *tx_flags = HCKSUM_INET_FULL_V4 | HCKSUM_IPHDRCKSUM; ret = B_TRUE; break; @@ -2082,17 +2149,17 @@ qede_mac_get_capability(void *arg, break; /* CASE MAC_CAPAB_RINGS */ } #ifdef ILLUMOS - case MAC_CAPAB_TRANSCEIVER: { - mac_capab_transceiver_t *mct = cap_data; + case MAC_CAPAB_TRANSCEIVER: { + mac_capab_transceiver_t *mct = cap_data; - mct->mct_flags = 0; - mct->mct_ntransceivers = qede->edev.num_hwfns; - mct->mct_info = qede_transceiver_info; - mct->mct_read = qede_transceiver_read; + mct->mct_flags = 0; + mct->mct_ntransceivers = qede->edev.num_hwfns; + mct->mct_info = qede_transceiver_info; + mct->mct_read = qede_transceiver_read; - ret = B_TRUE; - break; - } + ret = B_TRUE; + break; + } #endif default: break; @@ -2116,30 +2183,77 @@ qede_mac_set_property(void * arg, struct ecore_dev *edev = &qede->edev; struct ecore_hwfn *hwfn; int ret_val = 0, i; + uint32_t option; mutex_enter(&qede->gld_lock); switch (pr_num) { + case MAC_PROP_MTU: + bcopy(pr_val, &option, sizeof (option)); + + if(option == qede->mtu) { + ret_val = 0; + break; + } + if ((option != DEFAULT_JUMBO_MTU) && + (option != DEFAULT_MTU)) { + ret_val = EINVAL; + break; + } + if(qede->qede_state == QEDE_STATE_STARTED) { + ret_val = EBUSY; + break; + } + + ret_val = mac_maxsdu_update(qede->mac_handle, qede->mtu); + if (ret_val == 0) { + + qede->mtu = option; + if (option == DEFAULT_JUMBO_MTU) { + qede->jumbo_enable = B_TRUE; + } else { + qede->jumbo_enable = B_FALSE; + } + + hwfn = ECORE_LEADING_HWFN(edev); + hwfn->hw_info.mtu = qede->mtu; + ret_val = ecore_mcp_ov_update_mtu(hwfn, + hwfn->p_main_ptt, + hwfn->hw_info.mtu); + if (ret_val != ECORE_SUCCESS) { + qede_print("!%s(%d): MTU change %d option %d" + "FAILED", + __func__,qede->instance, qede->mtu, option); + break; + } + qede_print("!%s(%d): MTU changed %d MTU option" + " %d hwfn %d", + __func__,qede->instance, qede->mtu, + option, hwfn->hw_info.mtu); + } + break; + case MAC_PROP_EN_10GFDX_CAP: hwfn = &edev->hwfns[0]; link_params = ecore_mcp_get_link_params(hwfn); - if(*(uint8_t *) pr_val){ + if (*(uint8_t *) pr_val) { link_params->speed.autoneg = 0; link_params->speed.forced_speed = 10000; - link_params->speed.advertised_speeds = NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_10G; + link_params->speed.advertised_speeds = + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_10G; qede->forced_speed_10G = *(uint8_t *)pr_val; } else { - memcpy(link_params, &qede->link_input_params.default_link_params, - sizeof(struct ecore_mcp_link_params)); + memcpy(link_params, + &qede->link_input_params.default_link_params, + sizeof (struct ecore_mcp_link_params)); qede->forced_speed_10G = *(uint8_t *)pr_val; } - if(qede->qede_state == QEDE_STATE_STARTED){ + if (qede->qede_state == QEDE_STATE_STARTED) { qede_configure_link(qede,1); - } - else{ + } else { mutex_exit(&qede->gld_lock); - return 0; + return (0); } break; default: @@ -2147,13 +2261,13 @@ qede_mac_set_property(void * arg, break; } mutex_exit(&qede->gld_lock); - return ret_val; + return (ret_val); } static void -qede_mac_stop(void * arg) +qede_mac_stop(void *arg) { - qede_t * qede = (qede_t *)arg; + qede_t *qede = (qede_t *)arg; int status; qede_print("!%s(%d): called", @@ -2171,14 +2285,15 @@ qede_mac_stop(void * arg) } static int -qede_mac_start(void * arg) +qede_mac_start(void *arg) { - qede_t * qede = (qede_t *)arg; + qede_t *qede = (qede_t *)arg; int status; qede_print("!%s(%d): called", __func__,qede->instance); - if (!mutex_tryenter(&qede->drv_lock)) + if (!mutex_tryenter(&qede->drv_lock)) { return (EAGAIN); + } if (qede->qede_state == QEDE_STATE_SUSPENDED) { mutex_exit(&qede->drv_lock); @@ -2186,7 +2301,7 @@ qede_mac_start(void * arg) } status = qede_start(qede); - if(status != DDI_SUCCESS) { + if (status != DDI_SUCCESS) { mutex_exit(&qede->drv_lock); return (EIO); } @@ -2200,28 +2315,26 @@ qede_mac_start(void * arg) } static int -qede_mac_get_property(void * arg, - const char * pr_name, - mac_prop_id_t pr_num, - uint_t pr_valsize, - void * pr_val) +qede_mac_get_property(void *arg, + const char *pr_name, + mac_prop_id_t pr_num, + uint_t pr_valsize, + void *pr_val) { - qede_t * qede = (qede_t *)arg; + qede_t *qede = (qede_t *)arg; struct ecore_dev *edev = &qede->edev; link_state_t link_state; link_duplex_t link_duplex; uint64_t link_speed; link_flowctrl_t link_flowctrl; struct qede_link_cfg link_cfg; - qede_link_cfg_t * hw_cfg = &qede->hwinit; + qede_link_cfg_t *hw_cfg = &qede->hwinit; int ret_val = 0; - memset(&link_cfg, 0, sizeof(struct qede_link_cfg)); + memset(&link_cfg, 0, sizeof (struct qede_link_cfg)); qede_get_link_info(&edev->hwfns[0], &link_cfg); - /*mutex_enter(&qede->drv_lock); - mutex_exit(&qede->drv_lock);*/ switch (pr_num) { @@ -2270,34 +2383,29 @@ qede_mac_get_property(void * arg, * illumos does not have the notion of LINK_FLOWCTRL_AUTO at this time. */ #ifndef ILLUMOS - if(link_cfg.pause_cfg & QEDE_LINK_PAUSE_AUTONEG_ENABLE) - { + if (link_cfg.pause_cfg & QEDE_LINK_PAUSE_AUTONEG_ENABLE) { link_flowctrl = LINK_FLOWCTRL_AUTO; } #endif if (!(link_cfg.pause_cfg & QEDE_LINK_PAUSE_RX_ENABLE) && - !(link_cfg.pause_cfg & QEDE_LINK_PAUSE_TX_ENABLE)) - { + !(link_cfg.pause_cfg & QEDE_LINK_PAUSE_TX_ENABLE)) { link_flowctrl = LINK_FLOWCTRL_NONE; } if ((link_cfg.pause_cfg & QEDE_LINK_PAUSE_RX_ENABLE) && - !(link_cfg.pause_cfg & QEDE_LINK_PAUSE_TX_ENABLE)) - { + !(link_cfg.pause_cfg & QEDE_LINK_PAUSE_TX_ENABLE)) { link_flowctrl = LINK_FLOWCTRL_RX; } if (!(link_cfg.pause_cfg & QEDE_LINK_PAUSE_RX_ENABLE) && - (link_cfg.pause_cfg & QEDE_LINK_PAUSE_TX_ENABLE)) - { + (link_cfg.pause_cfg & QEDE_LINK_PAUSE_TX_ENABLE)) { link_flowctrl = LINK_FLOWCTRL_TX; } if ((link_cfg.pause_cfg & QEDE_LINK_PAUSE_RX_ENABLE) && - (link_cfg.pause_cfg & QEDE_LINK_PAUSE_TX_ENABLE)) - { + (link_cfg.pause_cfg & QEDE_LINK_PAUSE_TX_ENABLE)) { link_flowctrl = LINK_FLOWCTRL_BI; } - bcopy(&link_flowctrl, pr_val, sizeof(link_flowctrl_t)); + bcopy(&link_flowctrl, pr_val, sizeof (link_flowctrl_t)); break; case MAC_PROP_ADV_10GFDX_CAP: @@ -2310,25 +2418,23 @@ qede_mac_get_property(void * arg, case MAC_PROP_PRIVATE: default: - return ENOTSUP; + return (ENOTSUP); } - return(0); + return (0); } static void -qede_mac_property_info(void * arg, - const char * pr_name, - mac_prop_id_t pr_num, - mac_prop_info_handle_t prh) +qede_mac_property_info(void *arg, + const char *pr_name, + mac_prop_id_t pr_num, + mac_prop_info_handle_t prh) { - qede_t * qede = (qede_t *)arg; + qede_t *qede = (qede_t *)arg; qede_link_props_t *def_cfg = &qede_def_link_props; link_flowctrl_t link_flowctrl; - /*mutex_enter(&qede->drv_lock); - mutex_exit(&qede->drv_lock);*/ switch (pr_num) { @@ -2342,8 +2448,8 @@ qede_mac_property_info(void * arg, case MAC_PROP_MTU: mac_prop_info_set_range_uint32(prh, - MIN_MTU, - MAX_MTU); + MIN_MTU, + MAX_MTU); break; case MAC_PROP_AUTONEG: @@ -2353,10 +2459,11 @@ qede_mac_property_info(void * arg, case MAC_PROP_FLOWCTRL: - if(!def_cfg->pause) + if (!def_cfg->pause) { link_flowctrl = LINK_FLOWCTRL_NONE; - else + } else { link_flowctrl = LINK_FLOWCTRL_BI; + } mac_prop_info_set_default_link_flowctrl(prh, link_flowctrl); break; @@ -2410,7 +2517,7 @@ static mac_callbacks_t qede_callbacks = }; boolean_t -qede_gld_init(qede_t * qede) +qede_gld_init(qede_t *qede) { int status, ret; mac_register_t *macp; @@ -2418,7 +2525,7 @@ qede_gld_init(qede_t * qede) macp = mac_alloc(MAC_VERSION); if (macp == NULL) { cmn_err(CE_NOTE, "%s: mac_alloc() failed\n", __func__); - return(B_FALSE); + return (B_FALSE); } macp->m_driver = qede; @@ -2436,18 +2543,20 @@ qede_gld_init(qede_t * qede) #endif status = mac_register(macp, &qede->mac_handle); - if (status != 0) + if (status != 0) { cmn_err(CE_NOTE, "%s: mac_register() failed\n", __func__); + } mac_free(macp); - if (status == 0) - return(B_TRUE); - return(B_FALSE); + if (status == 0) { + return (B_TRUE); + } + return (B_FALSE); } boolean_t qede_gld_fini(qede_t * qede) { - return B_TRUE; + return (B_TRUE); } diff --git a/usr/src/uts/common/io/qede/qede_kstat.c b/usr/src/uts/common/io/qede/qede_kstat.c index 431b6b4304..008abfa5f7 100644 --- a/usr/src/uts/common/io/qede/qede_kstat.c +++ b/usr/src/uts/common/io/qede/qede_kstat.c @@ -36,9 +36,7 @@ #include "qede.h" -typedef struct _qede_kstat -{ - +typedef struct _qede_kstat { kstat_named_t qede_hi; kstat_named_t qede_lo; kstat_named_t version; @@ -65,62 +63,62 @@ typedef struct _qede_kstat kstat_named_t rxTotalPkts; kstat_named_t rxTotalBytes; kstat_named_t rxTotalDiscards; + kstat_named_t allocbFailures; } qede_kstat_t; -#define QEDE_KSTAT_SIZE (sizeof(qede_kstat_t) / sizeof(kstat_named_t)) +#define QEDE_KSTAT_SIZE (sizeof (qede_kstat_t) / sizeof (kstat_named_t)) -typedef struct _qede_kstat_link -{ - kstat_named_t vportID; - kstat_named_t uptime; - kstat_named_t mtuL2; - kstat_named_t speed; - kstat_named_t link; - kstat_named_t duplex; - kstat_named_t pauseRx; - kstat_named_t pauseTx; +typedef struct _qede_kstat_link { + kstat_named_t vportID; + kstat_named_t uptime; + kstat_named_t mtuL2; + kstat_named_t speed; + kstat_named_t link; + kstat_named_t duplex; + kstat_named_t pauseRx; + kstat_named_t pauseTx; } qede_kstat_link_t; -#define QEDE_KSTAT_LINK_SIZE (sizeof(qede_kstat_link_t) / sizeof(kstat_named_t)) +#define QEDE_KSTAT_LINK_SIZE \ + (sizeof (qede_kstat_link_t) / sizeof (kstat_named_t)) -typedef struct _qede_kstat_intr -{ - kstat_named_t intrAlloc; - kstat_named_t intrFired; - kstat_named_t sb_00; - kstat_named_t sb_01; - kstat_named_t sb_02; - kstat_named_t sb_03; - kstat_named_t sb_04; - kstat_named_t sb_05; - kstat_named_t sb_06; - kstat_named_t sb_nc_00; - kstat_named_t sb_nc_01; - kstat_named_t sb_nc_02; - kstat_named_t sb_nc_03; - kstat_named_t sb_nc_04; - kstat_named_t sb_nc_05; - kstat_named_t sb_nc_06; - kstat_named_t sb_poll_00; - kstat_named_t sb_poll_01; - kstat_named_t sb_poll_02; - kstat_named_t sb_poll_03; - kstat_named_t sb_poll_04; - kstat_named_t sb_poll_05; - kstat_named_t sb_poll_06; - kstat_named_t sb_poll_nc_00; - kstat_named_t sb_poll_nc_01; - kstat_named_t sb_poll_nc_02; - kstat_named_t sb_poll_nc_03; - kstat_named_t sb_poll_nc_04; - kstat_named_t sb_poll_nc_05; +typedef struct _qede_kstat_intr { + kstat_named_t intrAlloc; + kstat_named_t intrFired; + kstat_named_t sb_00; + kstat_named_t sb_01; + kstat_named_t sb_02; + kstat_named_t sb_03; + kstat_named_t sb_04; + kstat_named_t sb_05; + kstat_named_t sb_06; + kstat_named_t sb_nc_00; + kstat_named_t sb_nc_01; + kstat_named_t sb_nc_02; + kstat_named_t sb_nc_03; + kstat_named_t sb_nc_04; + kstat_named_t sb_nc_05; + kstat_named_t sb_nc_06; + kstat_named_t sb_poll_00; + kstat_named_t sb_poll_01; + kstat_named_t sb_poll_02; + kstat_named_t sb_poll_03; + kstat_named_t sb_poll_04; + kstat_named_t sb_poll_05; + kstat_named_t sb_poll_06; + kstat_named_t sb_poll_nc_00; + kstat_named_t sb_poll_nc_01; + kstat_named_t sb_poll_nc_02; + kstat_named_t sb_poll_nc_03; + kstat_named_t sb_poll_nc_04; + kstat_named_t sb_poll_nc_05; kstat_named_t sb_poll_nc_06; } qede_kstat_intr_t; -#define QEDE_KSTAT_INTR_SIZE (sizeof(qede_kstat_intr_t) / sizeof(kstat_named_t)) +#define QEDE_KSTAT_INTR_SIZE \ + (sizeof (qede_kstat_intr_t) / sizeof (kstat_named_t)) -typedef struct _qede_kstat_vport_stats -{ +typedef struct _qede_kstat_vport_stats { kstat_named_t rxUcastBytes; kstat_named_t rxMcastBytes; kstat_named_t rxBcastBytes; @@ -178,136 +176,145 @@ typedef struct _qede_kstat_vport_stats kstat_named_t coalescedBytes; } qede_kstat_vport_stats_t; -#define QEDE_KSTAT_VPORT_STATS_SIZE (sizeof(qede_kstat_vport_stats_t) / sizeof(kstat_named_t)) - -typedef struct _qede_kstat_rxq -{ - kstat_named_t rxqBdTotal; - kstat_named_t rxqBdLeft; - kstat_named_t rxqBdPageCnt; - kstat_named_t rxqBdsPerPage; - kstat_named_t rxqBdSize; - kstat_named_t rxqBdProdIdx; - kstat_named_t rxqBdConsIdx; - kstat_named_t rcqBdTotal; - kstat_named_t rcqBdLeft; - kstat_named_t rcqBdPageCnt; - kstat_named_t rcqBdsPerPage; - kstat_named_t rcqBdSize; - kstat_named_t rcqBdProdIdx; - kstat_named_t rcqBdConsIdx; - kstat_named_t hwRcqConIdx; - kstat_named_t rxFreeDescs; - kstat_named_t rxActiveDescs; - kstat_named_t rxCopyPkts; - kstat_named_t rxDropPkts; - kstat_named_t rxBufUpInStack; - kstat_named_t rxLowWater; - kstat_named_t rxLowWaterCnt; - kstat_named_t inPollMode; - kstat_named_t rxPollCnt; - kstat_named_t intrDisableCnt; - kstat_named_t intrEnableCnt; - kstat_named_t genNumber; - kstat_named_t rxRegPkts; - kstat_named_t rxJumboPkts; - kstat_named_t rxLroPkts; - kstat_named_t rxRingTotalPkts; - kstat_named_t rxRingTotalBytes; +#define QEDE_KSTAT_VPORT_STATS_SIZE \ + (sizeof (qede_kstat_vport_stats_t) / sizeof (kstat_named_t)) + +typedef struct _qede_kstat_rxq { + kstat_named_t rxqBdTotal; + kstat_named_t rxqBdLeft; + kstat_named_t rxqBdPageCnt; + kstat_named_t rxqBdsPerPage; + kstat_named_t rxqBdSize; + kstat_named_t rxqBdProdIdx; + kstat_named_t rxqBdConsIdx; + kstat_named_t rcqBdTotal; + kstat_named_t rcqBdLeft; + kstat_named_t rcqBdPageCnt; + kstat_named_t rcqBdsPerPage; + kstat_named_t rcqBdSize; + kstat_named_t rcqBdProdIdx; + kstat_named_t rcqBdConsIdx; + kstat_named_t hwRcqConIdx; + kstat_named_t rxFreeDescs; + kstat_named_t rxActiveDescs; + kstat_named_t rxCopyPkts; + kstat_named_t rxDropPkts; + kstat_named_t rxBufUpInStack; + kstat_named_t rxLowWater; + kstat_named_t rxLowWaterCnt; + kstat_named_t inPollMode; + kstat_named_t rxPollCnt; + kstat_named_t intrDisableCnt; + kstat_named_t intrEnableCnt; + kstat_named_t genNumber; + kstat_named_t rxRegPkts; + kstat_named_t rxJumboPkts; + kstat_named_t rxLroPkts; + kstat_named_t rxRingTotalPkts; + kstat_named_t rxRingTotalBytes; } qede_kstat_rxq_t; -#define QEDE_KSTAT_RXQ_SIZE (sizeof(qede_kstat_rxq_t) / sizeof(kstat_named_t)) - -typedef struct _qede_kstat_txq -{ - kstat_named_t txBdTotal; - kstat_named_t txBdLeft; - kstat_named_t txBdPageCnt; - kstat_named_t txBdsPerPage; - kstat_named_t txBdSize; - kstat_named_t hwTxqConIdx; - kstat_named_t txBdProdIdx; - kstat_named_t txBdConsIdx; - kstat_named_t txLowWater; - kstat_named_t txRingPause; - kstat_named_t txDropPkts; - kstat_named_t txCopyPkts; - kstat_named_t txBind; - kstat_named_t txBindFail; - kstat_named_t txPremapped; - kstat_named_t txPremappedFail; - kstat_named_t txTooManyCookies; - kstat_named_t txPullupPkts; - kstat_named_t txLsoPkts; - kstat_named_t txTooManyMblks; - kstat_named_t txMappedPkts; - kstat_named_t txJumboPkts; - kstat_named_t txRingTotalPkts; - kstat_named_t txRingTotalBytes; +#define QEDE_KSTAT_RXQ_SIZE \ + (sizeof (qede_kstat_rxq_t) / sizeof (kstat_named_t)) + +typedef struct _qede_kstat_txq { + kstat_named_t txBdTotal; + kstat_named_t txBdLeft; + kstat_named_t txBdPageCnt; + kstat_named_t txBdsPerPage; + kstat_named_t txBdSize; + kstat_named_t hwTxqConIdx; + kstat_named_t txBdProdIdx; + kstat_named_t txBdConsIdx; + kstat_named_t txLowWater; + kstat_named_t txRingPause; + kstat_named_t txDropPkts; + kstat_named_t txCopyPkts; + kstat_named_t txBind; + kstat_named_t txBindFail; + kstat_named_t txPremapped; + kstat_named_t txPremappedFail; + kstat_named_t txTooManyCookies; + kstat_named_t txPullupPkts; + kstat_named_t txLsoPkts; + kstat_named_t txTooManyMblks; + kstat_named_t txMappedPkts; + kstat_named_t txJumboPkts; + kstat_named_t txRingTotalPkts; + kstat_named_t txRingTotalBytes; } qede_kstat_txq_t; -#define QEDE_KSTAT_TXQ_SIZE (sizeof(qede_kstat_txq_t) / sizeof(kstat_named_t)) - +#define QEDE_KSTAT_TXQ_SIZE \ + (sizeof (qede_kstat_txq_t) / sizeof (kstat_named_t)) -static int qede_kstat_update(kstat_t * kstats, - int rw) +static int +qede_kstat_update(kstat_t *kstats, + int rw) { - qede_kstat_t * pStats = (qede_kstat_t *)kstats->ks_data; + qede_kstat_t *pStats = (qede_kstat_t *)kstats->ks_data; qede_t *qede = (qede_t *)kstats->ks_private; - struct ecore_dev * edev = &qede->edev; - struct ecore_hwfn *p_hwfn = &edev->hwfns[0]; + struct ecore_dev *edev = &qede->edev; qede_fastpath_t *fp = &qede->fp_array[0]; qede_rx_ring_t *rx_ring; qede_tx_ring_t *tx_ring; - int i,j; + int i, j; char buf[17]; - if (rw == KSTAT_WRITE) - { + if (rw == KSTAT_WRITE) { return EACCES; } mutex_enter(&qede->kstat_lock); - snprintf(buf, sizeof(buf), "%16p", (void *)qede); - strncpy(pStats->qede_hi.value.c, &buf[0], 8); - pStats->qede_hi.value.c[8] = 0; - strncpy(pStats->qede_lo.value.c, &buf[8], 8); - pStats->qede_lo.value.c[8] = 0; + snprintf(buf, sizeof (buf), "%16p", (void *)qede); + strncpy(pStats->qede_hi.value.c, &buf[0], 8); + pStats->qede_hi.value.c[8] = 0; + strncpy(pStats->qede_lo.value.c, &buf[8], 8); + pStats->qede_lo.value.c[8] = 0; - strncpy(pStats->version.value.c, qede->version, sizeof(pStats->version.value.c)); - strncpy(pStats->versionFW.value.c, qede->versionFW, sizeof(pStats->versionFW.value.c)); - strncpy(pStats->versionMFW.value.c, qede->versionMFW, sizeof(pStats->versionMFW.value.c)); + strncpy(pStats->version.value.c, + qede->version, sizeof (pStats->version.value.c)); + strncpy(pStats->versionFW.value.c, + qede->versionFW, sizeof (pStats->versionFW.value.c)); + strncpy(pStats->versionMFW.value.c, + qede->versionMFW, sizeof (pStats->versionMFW.value.c)); - strncpy(pStats->chipName.value.c, qede->chip_name, sizeof(pStats->chipName.value.c)); - strncpy(pStats->chipID.value.c, qede->chipID, sizeof(pStats->chipID.value.c)); + strncpy(pStats->chipName.value.c, + qede->chip_name, sizeof (pStats->chipName.value.c)); + strncpy(pStats->chipID.value.c, + qede->chipID, sizeof (pStats->chipID.value.c)); - strncpy(pStats->devBDF.value.c, qede->bus_dev_func, sizeof(pStats->devBDF.value.c)); - strncpy(pStats->devID.value.c, qede->vendor_device, sizeof(pStats->devID.value.c)); + strncpy(pStats->devBDF.value.c, + qede->bus_dev_func, sizeof (pStats->devBDF.value.c)); + strncpy(pStats->devID.value.c, + qede->vendor_device, sizeof (pStats->devID.value.c)); - strncpy(pStats->multiFunction.value.c, - ((edev->mf_mode == ECORE_MF_DEFAULT) ? "DEFAULT" : - (edev->mf_mode == ECORE_MF_OVLAN) ? "MF-OVLAN" : "Unknown"), - sizeof(pStats->multiFunction.value.c)); + strncpy(pStats->multiFunction.value.c, + ((edev->mf_mode == ECORE_MF_DEFAULT) ? "DEFAULT" : + (edev->mf_mode == ECORE_MF_OVLAN) ? "MF-OVLAN" : "Unknown"), + sizeof (pStats->multiFunction.value.c)); - pStats->multiFunctionVnics.value.ui64 = 0; + pStats->multiFunctionVnics.value.ui64 = 0; - snprintf(pStats->macAddr.value.c, 16, "%02x%02x%02x%02x%02x%02x", - qede->ether_addr[0],qede->ether_addr[1], - qede->ether_addr[2], qede->ether_addr[3], - qede->ether_addr[4],qede->ether_addr[5]); + snprintf(pStats->macAddr.value.c, 16, "%02x%02x%02x%02x%02x%02x", + qede->ether_addr[0],qede->ether_addr[1], + qede->ether_addr[2], qede->ether_addr[3], + qede->ether_addr[4],qede->ether_addr[5]); - pStats->hwInitDone.value.ui64 = (qede->attach_resources & QEDE_ECORE_HW_INIT)? 1 : 0; - /*pStats->numVports.value.ui64 = p_hwfn->hw_info.resc_num[ECORE_VPORT]; */ - pStats->numVports.value.ui64 = edev->num_hwfns; - pStats->vportID.value.ui64 = qede->vport_params[0].vport_id; + pStats->hwInitDone.value.ui64 = + (qede->attach_resources & QEDE_ECORE_HW_INIT)? 1 : 0; + /*pStats->numVports.value.ui64 = + p_hwfn->hw_info.resc_num[ECORE_VPORT]; */ + pStats->numVports.value.ui64 = edev->num_hwfns; + pStats->vportID.value.ui64 = qede->vport_params[0].vport_id; - strncpy(pStats->intrAlloc.value.c, qede->intrAlloc, sizeof(pStats->intrAlloc.value.c)); + strncpy(pStats->intrAlloc.value.c, + qede->intrAlloc, sizeof (pStats->intrAlloc.value.c)); pStats->intrFired.value.ui64 = qede->intrFired; pStats->lroEnabled.value.ui64 = qede->lro_enable; @@ -320,6 +327,7 @@ static int qede_kstat_update(kstat_t * kstats, qede->txTotalPkts = 0; qede->txTotalBytes = 0; qede->txTotalDiscards = 0; + qede->allocbFailures = 0; for (i = 0; i < qede->num_fp; i++, fp++) { rx_ring = fp->rx_ring; qede->rxTotalPkts += rx_ring->rx_pkt_cnt; @@ -338,22 +346,21 @@ static int qede_kstat_update(kstat_t * kstats, pStats->txTotalPkts.value.ui64 = qede->txTotalPkts; pStats->txTotalBytes.value.ui64 = qede->txTotalBytes; pStats->txTotalDiscards.value.ui64 = qede->txTotalDiscards; + pStats->allocbFailures.value.ui64 = qede->allocbFailures; mutex_exit(&qede->kstat_lock); - return 0; + return (0); } static int -qede_kstat_link_update(kstat_t * kstats, int rw) +qede_kstat_link_update(kstat_t *kstats, int rw) { qede_kstat_link_t *pStats = (qede_kstat_link_t *)kstats->ks_data; qede_t *qede = (qede_t *)kstats->ks_private; - struct ecore_dev * edev = &qede->edev; - struct ecore_hwfn *p_hwfn = &edev->hwfns[0]; + struct ecore_dev *edev = &qede->edev; - if (rw == KSTAT_WRITE) - { + if (rw == KSTAT_WRITE) { return EACCES; } mutex_enter(&qede->kstat_lock); @@ -369,40 +376,38 @@ qede_kstat_link_update(kstat_t * kstats, int rw) pStats->pauseTx.value.ui64 = qede->props.tx_pause; mutex_exit(&qede->kstat_lock); - return 0; + return (0); } static int -qede_kstat_intr_update(kstat_t * kstats, int rw) +qede_kstat_intr_update(kstat_t *kstats, int rw) { qede_kstat_intr_t * pStats = (qede_kstat_intr_t *)kstats->ks_data; qede_t *qede = (qede_t *)kstats->ks_private; - struct ecore_dev * edev = &qede->edev; - struct ecore_hwfn *p_hwfn = &edev->hwfns[0]; - + struct ecore_dev *edev = &qede->edev; - if (rw == KSTAT_WRITE) - { - return EACCES; - } + if (rw == KSTAT_WRITE) { + return EACCES; + } mutex_enter(&qede->kstat_lock); - strncpy(pStats->intrAlloc.value.c, qede->intrAlloc, sizeof(pStats->intrAlloc.value.c)); + strncpy(pStats->intrAlloc.value.c, + qede->intrAlloc, sizeof (pStats->intrAlloc.value.c)); pStats->intrFired.value.ui64 = qede->intrFired; - pStats->sb_00.value.ui64 = qede->intrSbCnt[0]; - pStats->sb_01.value.ui64 = qede->intrSbCnt[1]; - pStats->sb_02.value.ui64 = qede->intrSbCnt[2]; - pStats->sb_03.value.ui64 = qede->intrSbCnt[3]; - pStats->sb_04.value.ui64 = qede->intrSbCnt[4]; - pStats->sb_05.value.ui64 = qede->intrSbCnt[5]; - pStats->sb_06.value.ui64 = qede->intrSbCnt[6]; + pStats->sb_00.value.ui64 = qede->intrSbCnt[0]; + pStats->sb_01.value.ui64 = qede->intrSbCnt[1]; + pStats->sb_02.value.ui64 = qede->intrSbCnt[2]; + pStats->sb_03.value.ui64 = qede->intrSbCnt[3]; + pStats->sb_04.value.ui64 = qede->intrSbCnt[4]; + pStats->sb_05.value.ui64 = qede->intrSbCnt[5]; + pStats->sb_06.value.ui64 = qede->intrSbCnt[6]; - pStats->sb_nc_00.value.ui64 = qede->intrSbNoChangeCnt[0]; + pStats->sb_nc_00.value.ui64 = qede->intrSbNoChangeCnt[0]; pStats->sb_nc_01.value.ui64 = qede->intrSbNoChangeCnt[1]; pStats->sb_nc_02.value.ui64 = qede->intrSbNoChangeCnt[2]; pStats->sb_nc_03.value.ui64 = qede->intrSbNoChangeCnt[3]; @@ -430,33 +435,32 @@ qede_kstat_intr_update(kstat_t * kstats, int rw) mutex_exit(&qede->kstat_lock); - return 0; + return (0); } static int -qede_kstat_vport_stats_update(kstat_t * kstats, int rw) +qede_kstat_vport_stats_update(kstat_t *kstats, int rw) { - qede_kstat_vport_stats_t * pStats = (qede_kstat_vport_stats_t *)kstats->ks_data; + qede_kstat_vport_stats_t *pStats = + (qede_kstat_vport_stats_t *)kstats->ks_data; qede_t *qede = (qede_t *)kstats->ks_private; struct ecore_dev * edev = &qede->edev; - struct ecore_hwfn *p_hwfn = &edev->hwfns[0]; struct ecore_eth_stats vstats; - if (rw == KSTAT_WRITE) - { - return EACCES; - } + if (rw == KSTAT_WRITE) { + return EACCES; + } mutex_enter(&qede->kstat_lock); - memset(&vstats, 0, sizeof(struct ecore_eth_stats)); - if(qede->qede_state == QEDE_STATE_STARTED) - { + memset(&vstats, 0, sizeof (struct ecore_eth_stats)); + if(qede->qede_state == QEDE_STATE_STARTED) { ecore_get_vport_stats(edev, &vstats); - memcpy(&qede->save_stats, &vstats, sizeof(struct ecore_eth_stats)); + memcpy(&qede->save_stats, &vstats, + sizeof (struct ecore_eth_stats)); } pStats->rxUcastBytes.value.ui64 = vstats.common.rx_ucast_bytes; @@ -472,72 +476,111 @@ qede_kstat_vport_stats_update(kstat_t * kstats, int rw) pStats->txMcastPkts.value.ui64 = vstats.common.tx_mcast_pkts; pStats->txBcastPkts.value.ui64 = vstats.common.tx_bcast_pkts; pStats->rx64bytePkts.value.ui64 = vstats.common.rx_64_byte_packets; - pStats->rx127bytePkts.value.ui64 = vstats.common.rx_65_to_127_byte_packets; - pStats->rx255bytePkts.value.ui64 = vstats.common.rx_128_to_255_byte_packets; - pStats->rx511bytePkts.value.ui64 = vstats.common.rx_256_to_511_byte_packets; - pStats->rx1023bytePkts.value.ui64 = vstats.common.rx_512_to_1023_byte_packets; - pStats->rx1518bytePkts.value.ui64 = vstats.common.rx_1024_to_1518_byte_packets; - pStats->rx1522bytePkts.value.ui64 = vstats.bb.rx_1519_to_1522_byte_packets; - pStats->rx2047bytePkts.value.ui64 = vstats.bb.rx_1519_to_2047_byte_packets; - pStats->rx4095bytePkts.value.ui64 = vstats.bb.rx_2048_to_4095_byte_packets; - pStats->rx9216bytePkts.value.ui64 = vstats.bb.rx_4096_to_9216_byte_packets; - pStats->rx16383bytePkts.value.ui64 = vstats.bb.rx_9217_to_16383_byte_packets; - pStats->tx64bytePkts.value.ui64 = vstats.common.tx_64_byte_packets; - pStats->tx64to127bytePkts.value.ui64 = vstats.common.tx_65_to_127_byte_packets; - pStats->tx128to255bytePkts.value.ui64 = vstats.common.tx_128_to_255_byte_packets; - pStats->tx256to511bytePkts.value.ui64 = vstats.common.tx_256_to_511_byte_packets; - pStats->tx512to1023bytePkts.value.ui64 = vstats.common.tx_512_to_1023_byte_packets; - pStats->tx1024to1518bytePkts.value.ui64 = vstats.common.tx_1024_to_1518_byte_packets; - pStats->tx1519to2047bytePkts.value.ui64 = vstats.bb.tx_1519_to_2047_byte_packets; - pStats->tx2048to4095bytePkts.value.ui64 = vstats.bb.tx_2048_to_4095_byte_packets; - pStats->tx4096to9216bytePkts.value.ui64 = vstats.bb.tx_4096_to_9216_byte_packets; - pStats->tx9217to16383bytePkts.value.ui64 = vstats.bb.tx_9217_to_16383_byte_packets; - pStats->rxMacCtrlFrames.value.ui64 = vstats.common.rx_mac_crtl_frames; - pStats->rxPauseFrames.value.ui64 = vstats.common.rx_pause_frames; - pStats->txPauseFrames.value.ui64 = vstats.common.tx_pause_frames; - pStats->rxCRCerrors.value.ui64 = vstats.common.rx_crc_errors; - pStats->rxAlignErrors.value.ui64 = vstats.common.rx_align_errors; - pStats->rxCarrierErrors.value.ui64 = vstats.common.rx_carrier_errors; - pStats->rxOversizeErrors.value.ui64 = vstats.common.rx_oversize_packets; - pStats->rxJabbers.value.ui64 = vstats.common.rx_jabbers; - pStats->rxUndersizePkts.value.ui64 = vstats.common.rx_undersize_packets; - pStats->rxFragments.value.ui64 = vstats.common.rx_fragments; - pStats->txLpiEntryCnt.value.ui64 = vstats.bb.tx_lpi_entry_count; - pStats->txTotalCollisions.value.ui64 = vstats.bb.tx_total_collisions; - pStats->brbTruncates.value.ui64 = vstats.common.brb_truncates; - pStats->noBuffDiscards.value.ui64 = vstats.common.no_buff_discards; - pStats->mftagFilterDiscards.value.ui64 = vstats.common.mftag_filter_discards; - pStats->macFilterDiscards.value.ui64 = vstats.common.mac_filter_discards; - pStats->txErrDropPkts.value.ui64 = vstats.common.tx_err_drop_pkts; - pStats->coalescedPkts.value.ui64 = vstats.common.tpa_coalesced_pkts; - pStats->coalescedEvents.value.ui64 = vstats.common.tpa_coalesced_events; - pStats->coalescedAbortsNum.value.ui64 = vstats.common.tpa_aborts_num; - pStats->nonCoalescedPkts.value.ui64 = vstats.common.tpa_not_coalesced_pkts; - pStats->coalescedBytes.value.ui64 = vstats.common.tpa_coalesced_bytes; + pStats->rx127bytePkts.value.ui64 = + vstats.common.rx_65_to_127_byte_packets; + pStats->rx255bytePkts.value.ui64 = + vstats.common.rx_128_to_255_byte_packets; + pStats->rx511bytePkts.value.ui64 = + vstats.common.rx_256_to_511_byte_packets; + pStats->rx1023bytePkts.value.ui64 = + vstats.common.rx_512_to_1023_byte_packets; + pStats->rx1518bytePkts.value.ui64 = + vstats.common.rx_1024_to_1518_byte_packets; + pStats->rx1522bytePkts.value.ui64 = + vstats.bb.rx_1519_to_1522_byte_packets; + pStats->rx2047bytePkts.value.ui64 = + vstats.bb.rx_1519_to_2047_byte_packets; + pStats->rx4095bytePkts.value.ui64 = + vstats.bb.rx_2048_to_4095_byte_packets; + pStats->rx9216bytePkts.value.ui64 = + vstats.bb.rx_4096_to_9216_byte_packets; + pStats->rx16383bytePkts.value.ui64 = + vstats.bb.rx_9217_to_16383_byte_packets; + pStats->tx64bytePkts.value.ui64 = + vstats.common.tx_64_byte_packets; + pStats->tx64to127bytePkts.value.ui64 = + vstats.common.tx_65_to_127_byte_packets; + pStats->tx128to255bytePkts.value.ui64 = + vstats.common.tx_128_to_255_byte_packets; + pStats->tx256to511bytePkts.value.ui64 = + vstats.common.tx_256_to_511_byte_packets; + pStats->tx512to1023bytePkts.value.ui64 = + vstats.common.tx_512_to_1023_byte_packets; + pStats->tx1024to1518bytePkts.value.ui64 = + vstats.common.tx_1024_to_1518_byte_packets; + pStats->tx1519to2047bytePkts.value.ui64 = + vstats.bb.tx_1519_to_2047_byte_packets; + pStats->tx2048to4095bytePkts.value.ui64 = + vstats.bb.tx_2048_to_4095_byte_packets; + pStats->tx4096to9216bytePkts.value.ui64 = + vstats.bb.tx_4096_to_9216_byte_packets; + pStats->tx9217to16383bytePkts.value.ui64 = + vstats.bb.tx_9217_to_16383_byte_packets; + pStats->rxMacCtrlFrames.value.ui64 = + vstats.common.rx_mac_crtl_frames; + pStats->rxPauseFrames.value.ui64 = + vstats.common.rx_pause_frames; + pStats->txPauseFrames.value.ui64 = + vstats.common.tx_pause_frames; + pStats->rxCRCerrors.value.ui64 = + vstats.common.rx_crc_errors; + pStats->rxAlignErrors.value.ui64 = + vstats.common.rx_align_errors; + pStats->rxCarrierErrors.value.ui64 = + vstats.common.rx_carrier_errors; + pStats->rxOversizeErrors.value.ui64 = + vstats.common.rx_oversize_packets; + pStats->rxJabbers.value.ui64 = + vstats.common.rx_jabbers; + pStats->rxUndersizePkts.value.ui64 = + vstats.common.rx_undersize_packets; + pStats->rxFragments.value.ui64 = + vstats.common.rx_fragments; + pStats->txLpiEntryCnt.value.ui64 = + vstats.bb.tx_lpi_entry_count; + pStats->txTotalCollisions.value.ui64 = + vstats.bb.tx_total_collisions; + pStats->brbTruncates.value.ui64 = + vstats.common.brb_truncates; + pStats->noBuffDiscards.value.ui64 = + vstats.common.no_buff_discards; + pStats->mftagFilterDiscards.value.ui64 = + vstats.common.mftag_filter_discards; + pStats->macFilterDiscards.value.ui64 = + vstats.common.mac_filter_discards; + pStats->txErrDropPkts.value.ui64 = + vstats.common.tx_err_drop_pkts; + pStats->coalescedPkts.value.ui64 = + vstats.common.tpa_coalesced_pkts; + pStats->coalescedEvents.value.ui64 = + vstats.common.tpa_coalesced_events; + pStats->coalescedAbortsNum.value.ui64 = + vstats.common.tpa_aborts_num; + pStats->nonCoalescedPkts.value.ui64 = + vstats.common.tpa_not_coalesced_pkts; + pStats->coalescedBytes.value.ui64 = + vstats.common.tpa_coalesced_bytes; mutex_exit(&qede->kstat_lock); - return 0; + return (0); } static int -qede_kstat_rxq_update(kstat_t * kstats, int rw) +qede_kstat_rxq_update(kstat_t *kstats, int rw) { - qede_kstat_rxq_t * pStats = (qede_kstat_rxq_t *)kstats->ks_data; - KstatRingMap * pMap = (KstatRingMap *)kstats->ks_private; - qede_t * qede = (qede_t *)pMap->qede; - int idx = pMap->idx; - struct ecore_dev * edev = &qede->edev; - struct ecore_hwfn *p_hwfn = &edev->hwfns[0]; - qede_fastpath_t *fp; - qede_rx_ring_t *rx_ring = &qede->rx_array[idx]; + qede_kstat_rxq_t *pStats = (qede_kstat_rxq_t *)kstats->ks_data; + KstatRingMap *pMap = (KstatRingMap *)kstats->ks_private; + qede_t *qede = (qede_t *)pMap->qede; + int idx = pMap->idx; + struct ecore_dev *edev = &qede->edev; + qede_rx_ring_t *rx_ring = &qede->rx_array[idx]; - if (rw == KSTAT_WRITE) - { - return EACCES; - } + if (rw == KSTAT_WRITE) { + return EACCES; + } mutex_enter(&qede->kstat_lock); @@ -548,35 +591,70 @@ qede_kstat_rxq_update(kstat_t * kstats, int rw) if(qede->qede_state == QEDE_STATE_STARTED) { - pStats->rxqBdLeft.value.ui64 = ecore_chain_get_elem_left(&rx_ring->rx_bd_ring); - pStats->rxqBdPageCnt.value.ui64 = ECORE_CHAIN_PAGE_CNT(qede->rx_ring_size, sizeof (struct eth_rx_bd), ECORE_CHAIN_MODE_NEXT_PTR); - pStats->rxqBdsPerPage.value.ui64 = ELEMS_PER_PAGE(sizeof (struct eth_rx_bd)); + pStats->rxqBdLeft.value.ui64 = + ecore_chain_get_elem_left(&rx_ring->rx_bd_ring); + pStats->rxqBdPageCnt.value.ui64 = + ECORE_CHAIN_PAGE_CNT(qede->rx_ring_size, + sizeof (struct eth_rx_bd), ECORE_CHAIN_MODE_NEXT_PTR); + pStats->rxqBdsPerPage.value.ui64 = + ELEMS_PER_PAGE(sizeof (struct eth_rx_bd)); pStats->rxqBdSize.value.ui64 = sizeof (struct eth_rx_bd); - pStats->rxqBdProdIdx.value.ui64 = ecore_chain_get_prod_idx(&rx_ring->rx_bd_ring) & (rx_ring->qede->rx_ring_size - 1); - pStats->rxqBdConsIdx.value.ui64 = ecore_chain_get_cons_idx(&rx_ring->rx_bd_ring) & (rx_ring->qede->rx_ring_size - 1); - pStats->rcqBdLeft.value.ui64 = ecore_chain_get_elem_left(&rx_ring->rx_cqe_ring); - pStats->rcqBdPageCnt.value.ui64 = ECORE_CHAIN_PAGE_CNT(qede->rx_ring_size, sizeof(union eth_rx_cqe), ECORE_CHAIN_MODE_PBL); - pStats->rcqBdsPerPage.value.ui64 = ELEMS_PER_PAGE(sizeof(union eth_rx_cqe)); - pStats->rcqBdSize.value.ui64 = sizeof(union eth_rx_cqe); - pStats->rcqBdProdIdx.value.ui64 = ecore_chain_get_prod_idx(&rx_ring->rx_cqe_ring) & (rx_ring->qede->rx_ring_size - 1); - pStats->rcqBdConsIdx.value.ui64 = ecore_chain_get_cons_idx(&rx_ring->rx_cqe_ring) & (rx_ring->qede->rx_ring_size - 1); - pStats->hwRcqConIdx.value.ui64 = (rx_ring->hw_cons_ptr != NULL) ? HOST_TO_LE_16(*rx_ring->hw_cons_ptr) & (rx_ring->qede->rx_ring_size - 1): 0; - pStats->rxFreeDescs.value.ui64 = rx_ring->rx_buf_area->passive_buf_list.num_entries; - pStats->rxActiveDescs.value.ui64 = rx_ring->rx_buf_area->active_buf_list.num_entries; - pStats->rxBufUpInStack.value.ui64 = rx_ring->rx_buf_area->buf_upstream; - pStats->rxCopyPkts.value.ui64 = rx_ring->rx_copy_cnt; - pStats->rxDropPkts.value.ui64 = rx_ring->rx_drop_cnt; - pStats->rxLowWaterCnt.value.ui64 = rx_ring->rx_low_water_cnt; - pStats->inPollMode.value.ui64 = rx_ring->fp->disabled_by_poll; - pStats->rxPollCnt.value.ui64 = rx_ring->rx_poll_cnt;; - pStats->intrDisableCnt.value.ui64 = rx_ring->intrDisableCnt; - pStats->intrEnableCnt.value.ui64 = rx_ring->intrEnableCnt; - pStats->genNumber.value.ui64 = rx_ring->mr_gen_num; - pStats->rxLroPkts.value.ui64 = rx_ring->rx_lro_pkt_cnt; - pStats->rxRingTotalPkts.value.ui64 = rx_ring->rx_pkt_cnt; - pStats->rxRingTotalBytes.value.ui64 = rx_ring->rx_byte_cnt; - pStats->rxRegPkts.value.ui64 = rx_ring->rx_reg_pkt_cnt; - pStats->rxJumboPkts.value.ui64 = rx_ring->rx_jumbo_pkt_cnt; + pStats->rxqBdProdIdx.value.ui64 = + ecore_chain_get_prod_idx(&rx_ring->rx_bd_ring) & + (rx_ring->qede->rx_ring_size - 1); + pStats->rxqBdConsIdx.value.ui64 = + ecore_chain_get_cons_idx(&rx_ring->rx_bd_ring) & + (rx_ring->qede->rx_ring_size - 1); + pStats->rcqBdLeft.value.ui64 = + ecore_chain_get_elem_left(&rx_ring->rx_cqe_ring); + pStats->rcqBdPageCnt.value.ui64 = + ECORE_CHAIN_PAGE_CNT(qede->rx_ring_size, + sizeof (union eth_rx_cqe), ECORE_CHAIN_MODE_PBL); + pStats->rcqBdsPerPage.value.ui64 = + ELEMS_PER_PAGE(sizeof (union eth_rx_cqe)); + pStats->rcqBdSize.value.ui64 = sizeof (union eth_rx_cqe); + pStats->rcqBdProdIdx.value.ui64 = + ecore_chain_get_prod_idx(&rx_ring->rx_cqe_ring) & + (rx_ring->qede->rx_ring_size - 1); + pStats->rcqBdConsIdx.value.ui64 = + ecore_chain_get_cons_idx(&rx_ring->rx_cqe_ring) & + (rx_ring->qede->rx_ring_size - 1); + pStats->hwRcqConIdx.value.ui64 = + (rx_ring->hw_cons_ptr != NULL) ? + HOST_TO_LE_16(*rx_ring->hw_cons_ptr) & + (rx_ring->qede->rx_ring_size - 1): 0; + pStats->rxFreeDescs.value.ui64 = + rx_ring->rx_buf_area->passive_buf_list.num_entries; + pStats->rxActiveDescs.value.ui64 = + rx_ring->rx_buf_area->active_buf_list.num_entries; + pStats->rxBufUpInStack.value.ui64 = + rx_ring->rx_buf_area->buf_upstream; + pStats->rxCopyPkts.value.ui64 = + rx_ring->rx_copy_cnt; + pStats->rxDropPkts.value.ui64 = + rx_ring->rx_drop_cnt; + pStats->rxLowWaterCnt.value.ui64 = + rx_ring->rx_low_water_cnt; + pStats->inPollMode.value.ui64 = + rx_ring->fp->disabled_by_poll; + pStats->rxPollCnt.value.ui64 = + rx_ring->rx_poll_cnt;; + pStats->intrDisableCnt.value.ui64 = + rx_ring->intrDisableCnt; + pStats->intrEnableCnt.value.ui64 = + rx_ring->intrEnableCnt; + pStats->genNumber.value.ui64 = + rx_ring->mr_gen_num; + pStats->rxLroPkts.value.ui64 = + rx_ring->rx_lro_pkt_cnt; + pStats->rxRingTotalPkts.value.ui64 = + rx_ring->rx_pkt_cnt; + pStats->rxRingTotalBytes.value.ui64 = + rx_ring->rx_byte_cnt; + pStats->rxRegPkts.value.ui64 = + rx_ring->rx_reg_pkt_cnt; + pStats->rxJumboPkts.value.ui64 = + rx_ring->rx_jumbo_pkt_cnt; } else { @@ -612,27 +690,24 @@ qede_kstat_rxq_update(kstat_t * kstats, int rw) } mutex_exit(&qede->kstat_lock); - return 0; + return (0); } static int -qede_kstat_txq_update(kstat_t * kstats, int rw) +qede_kstat_txq_update(kstat_t *kstats, int rw) { - qede_kstat_txq_t * pStats = (qede_kstat_txq_t *)kstats->ks_data; - KstatRingMap * pMap = (KstatRingMap *)kstats->ks_private; - qede_t * qede = (qede_t *)pMap->qede; - int idx = pMap->idx; + qede_kstat_txq_t *pStats = (qede_kstat_txq_t *)kstats->ks_data; + KstatRingMap *pMap = (KstatRingMap *)kstats->ks_private; + qede_t *qede = (qede_t *)pMap->qede; + int idx = pMap->idx; struct ecore_dev * edev = &qede->edev; - struct ecore_hwfn *p_hwfn = &edev->hwfns[0]; - qede_fastpath_t *fp; - qede_tx_ring_t *tx_ring = &qede->tx_array[0][idx]; + qede_tx_ring_t *tx_ring = &qede->tx_array[0][idx]; - if (rw == KSTAT_WRITE) - { - return EACCES; + if (rw == KSTAT_WRITE) { + return EACCES; } mutex_enter(&qede->kstat_lock); @@ -642,13 +717,22 @@ qede_kstat_txq_update(kstat_t * kstats, int rw) if(qede->qede_state == QEDE_STATE_STARTED) { - pStats->txBdLeft.value.ui64 = ecore_chain_get_elem_left(&tx_ring->tx_bd_ring); - pStats->txBdPageCnt.value.ui64 = ECORE_CHAIN_PAGE_CNT(tx_ring->bd_ring_size, sizeof (union eth_tx_bd_types), ECORE_CHAIN_MODE_PBL); - pStats->txBdsPerPage.value.ui64 = ELEMS_PER_PAGE(sizeof (union eth_tx_bd_types)); - pStats->hwTxqConIdx.value.ui64 = (tx_ring->hw_cons_ptr != NULL) ? HOST_TO_LE_16(*tx_ring->hw_cons_ptr) & TX_RING_MASK : 0; - pStats->txBdProdIdx.value.ui64 = ecore_chain_get_prod_idx(&tx_ring->tx_bd_ring) & TX_RING_MASK; - pStats->txBdConsIdx.value.ui64 = ecore_chain_get_cons_idx(&tx_ring->tx_bd_ring) & TX_RING_MASK; - pStats->txRingPause.value.ui64 = tx_ring->tx_ring_pause; + pStats->txBdLeft.value.ui64 = + ecore_chain_get_elem_left(&tx_ring->tx_bd_ring); + pStats->txBdPageCnt.value.ui64 = + ECORE_CHAIN_PAGE_CNT(tx_ring->bd_ring_size, + sizeof (union eth_tx_bd_types), ECORE_CHAIN_MODE_PBL); + pStats->txBdsPerPage.value.ui64 = + ELEMS_PER_PAGE(sizeof (union eth_tx_bd_types)); + pStats->hwTxqConIdx.value.ui64 = + (tx_ring->hw_cons_ptr != NULL) ? + HOST_TO_LE_16(*tx_ring->hw_cons_ptr) & TX_RING_MASK : 0; + pStats->txBdProdIdx.value.ui64 = + ecore_chain_get_prod_idx(&tx_ring->tx_bd_ring) & TX_RING_MASK; + pStats->txBdConsIdx.value.ui64 = + ecore_chain_get_cons_idx(&tx_ring->tx_bd_ring) & TX_RING_MASK; + pStats->txRingPause.value.ui64 = + tx_ring->tx_ring_pause; pStats->txDropPkts.value.ui64 = tx_ring->tx_pkt_dropped; pStats->txCopyPkts.value.ui64 = tx_ring->tx_copy_count; pStats->txBind.value.ui64 = tx_ring->tx_bind_count; @@ -692,151 +776,153 @@ qede_kstat_txq_update(kstat_t * kstats, int rw) } mutex_exit(&qede->kstat_lock); - return 0; + return (0); } - boolean_t qede_kstat_init_rxq(qede_t *qede, int idx) +boolean_t +qede_kstat_init_rxq(qede_t *qede, int idx) { - char buf[32]; + char buf[32]; - qede_kstat_rxq_t * pStatsRxq; + qede_kstat_rxq_t *pStatsRxq; #define QEDE_KSTAT_RXQ(f, t) kstat_named_init(&pStatsRxq->f, #f, t) - snprintf(buf, sizeof(buf), "rxq%d", idx); - - if ((qede->kstats_rxq[idx] = kstat_create("qede", - qede->instance, - buf, - "net", - KSTAT_TYPE_NAMED, - QEDE_KSTAT_RXQ_SIZE, - 0)) == NULL) - { - /*BnxeLogWarn(qede, "Failed to create rxq%d kstat", idx);*/ - cmn_err(CE_WARN, "Failed to create rxq%d kstat", idx); - return B_FALSE; - } + snprintf(buf, sizeof (buf), "rxq%d", idx); + + if ((qede->kstats_rxq[idx] = kstat_create("qede", + qede->instance, + buf, + "net", + KSTAT_TYPE_NAMED, + QEDE_KSTAT_RXQ_SIZE, + 0)) == NULL) + { + /*BnxeLogWarn(qede, "Failed to create rxq%d kstat", idx);*/ + cmn_err(CE_WARN, "Failed to create rxq%d kstat", idx); + return (B_FALSE); + } pStatsRxq = (qede_kstat_rxq_t *)qede->kstats_rxq[idx]->ks_data; - QEDE_KSTAT_RXQ(rxqBdTotal, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxqBdLeft, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxqBdPageCnt, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxqBdsPerPage, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxqBdSize, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxqBdProdIdx, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxqBdConsIdx, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rcqBdTotal, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rcqBdLeft, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rcqBdPageCnt, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rcqBdsPerPage, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rcqBdSize, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rcqBdProdIdx, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rcqBdConsIdx, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(hwRcqConIdx, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxFreeDescs, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxActiveDescs, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxCopyPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxDropPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxBufUpInStack, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxLowWater, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxLowWaterCnt, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(inPollMode, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxPollCnt, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(intrDisableCnt, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(intrEnableCnt, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(genNumber, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxRegPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxJumboPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxLroPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxRingTotalPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_RXQ(rxRingTotalBytes, KSTAT_DATA_UINT64); - - - qede->kstats_rxq_map[idx].idx = idx; - qede->kstats_rxq_map[idx].qede = qede; - - qede->kstats_rxq[idx]->ks_update = qede_kstat_rxq_update; - qede->kstats_rxq[idx]->ks_private = (void *)&qede->kstats_rxq_map[idx]; - - kstat_install(qede->kstats_rxq[idx]); - - return B_TRUE; + QEDE_KSTAT_RXQ(rxqBdTotal, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxqBdLeft, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxqBdPageCnt, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxqBdsPerPage, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxqBdSize, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxqBdProdIdx, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxqBdConsIdx, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rcqBdTotal, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rcqBdLeft, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rcqBdPageCnt, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rcqBdsPerPage, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rcqBdSize, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rcqBdProdIdx, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rcqBdConsIdx, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(hwRcqConIdx, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxFreeDescs, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxActiveDescs, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxCopyPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxDropPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxBufUpInStack, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxLowWater, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxLowWaterCnt, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(inPollMode, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxPollCnt, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(intrDisableCnt, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(intrEnableCnt, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(genNumber, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxRegPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxJumboPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxLroPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxRingTotalPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_RXQ(rxRingTotalBytes, KSTAT_DATA_UINT64); + + + qede->kstats_rxq_map[idx].idx = idx; + qede->kstats_rxq_map[idx].qede = qede; + + qede->kstats_rxq[idx]->ks_update = qede_kstat_rxq_update; + qede->kstats_rxq[idx]->ks_private = (void *)&qede->kstats_rxq_map[idx]; + + kstat_install(qede->kstats_rxq[idx]); + + return (B_TRUE); } -boolean_t qede_kstat_init_txq(qede_t *qede, int idx) +boolean_t +qede_kstat_init_txq(qede_t *qede, int idx) { char buf[32]; - qede_kstat_txq_t * pStatsTxq; + qede_kstat_txq_t *pStatsTxq; #define QEDE_KSTAT_TXQ(f, t) kstat_named_init(&pStatsTxq->f, #f, t) - snprintf(buf, sizeof(buf), "txq%d", idx); + snprintf(buf, sizeof (buf), "txq%d", idx); if ((qede->kstats_txq[idx] = kstat_create("qede", - qede->instance, - buf, - "net", - KSTAT_TYPE_NAMED, - QEDE_KSTAT_TXQ_SIZE, - 0)) == NULL) - { - /*BnxeLogWarn(qede, "Failed to create txq%d kstat", idx);*/ - cmn_err(CE_WARN, "Failed to create txq%d kstat", idx); - return B_FALSE; - } - - - pStatsTxq = (qede_kstat_txq_t *)qede->kstats_txq[idx]->ks_data; - - QEDE_KSTAT_TXQ(txBdTotal, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txBdLeft, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txBdPageCnt, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txBdsPerPage, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txBdSize, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(hwTxqConIdx, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txBdProdIdx, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txBdConsIdx, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txLowWater, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txDropPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txCopyPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txRingPause, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txDropPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txBind, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txBindFail, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txPremapped, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txPremappedFail, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txTooManyCookies, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txPullupPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txLsoPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txTooManyMblks, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txMappedPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txJumboPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txRingTotalPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_TXQ(txRingTotalBytes, KSTAT_DATA_UINT64); - - qede->kstats_txq_map[idx].idx = idx; - qede->kstats_txq_map[idx].qede = qede; - - qede->kstats_txq[idx]->ks_update = qede_kstat_txq_update; - qede->kstats_txq[idx]->ks_private = (void *)&qede->kstats_txq_map[idx]; - - kstat_install(qede->kstats_txq[idx]); - - return B_TRUE; + qede->instance, + buf, + "net", + KSTAT_TYPE_NAMED, + QEDE_KSTAT_TXQ_SIZE, + 0)) == NULL) { + /*BnxeLogWarn(qede, "Failed to create txq%d kstat", idx);*/ + cmn_err(CE_WARN, "Failed to create txq%d kstat", idx); + return (B_FALSE); + } + + + pStatsTxq = (qede_kstat_txq_t *)qede->kstats_txq[idx]->ks_data; + + QEDE_KSTAT_TXQ(txBdTotal, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txBdLeft, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txBdPageCnt, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txBdsPerPage, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txBdSize, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(hwTxqConIdx, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txBdProdIdx, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txBdConsIdx, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txLowWater, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txDropPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txCopyPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txRingPause, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txDropPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txBind, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txBindFail, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txPremapped, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txPremappedFail, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txTooManyCookies, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txPullupPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txLsoPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txTooManyMblks, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txMappedPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txJumboPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txRingTotalPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_TXQ(txRingTotalBytes, KSTAT_DATA_UINT64); + + qede->kstats_txq_map[idx].idx = idx; + qede->kstats_txq_map[idx].qede = qede; + + qede->kstats_txq[idx]->ks_update = qede_kstat_txq_update; + qede->kstats_txq[idx]->ks_private = (void *)&qede->kstats_txq_map[idx]; + + kstat_install(qede->kstats_txq[idx]); + + return (B_TRUE); } -boolean_t qede_kstat_init(qede_t *qede) +boolean_t +qede_kstat_init(qede_t *qede) { - qede_kstat_t * pStats; - qede_kstat_link_t * pStatsLink; - qede_kstat_intr_t * pStatsIntr; - qede_kstat_vport_stats_t *pStatsVport; - int i; + qede_kstat_t *pStats; + qede_kstat_link_t *pStatsLink; + qede_kstat_intr_t *pStatsIntr; + qede_kstat_vport_stats_t *pStatsVport; + int i; #define QEDE_KSTAT(f, t) kstat_named_init(&pStats->f, #f, t) #define QEDE_KSTAT_LINK(f, t) kstat_named_init(&pStatsLink->f, #f, t) @@ -844,18 +930,17 @@ boolean_t qede_kstat_init(qede_t *qede) #define QEDE_KSTAT_VPORT(f,t) kstat_named_init(&pStatsVport->f, #f, t) - if ((qede->kstats = kstat_create("qede", - qede->instance, - "stats", - "net", - KSTAT_TYPE_NAMED, - QEDE_KSTAT_SIZE, - 0)) == NULL) - { - /*QedeLogWarn(qede, "Failed to create kstat");*/ - cmn_err(CE_WARN, "Failed to create kstat"); - return B_FALSE; - } + if ((qede->kstats = kstat_create("qede", + qede->instance, + "stats", + "net", + KSTAT_TYPE_NAMED, + QEDE_KSTAT_SIZE, + 0)) == NULL) { + /*QedeLogWarn(qede, "Failed to create kstat");*/ + cmn_err(CE_WARN, "Failed to create kstat"); + return (B_FALSE); + } pStats = (qede_kstat_t *)qede->kstats->ks_data; QEDE_KSTAT(qede_hi, KSTAT_DATA_CHAR); @@ -884,6 +969,7 @@ boolean_t qede_kstat_init(qede_t *qede) QEDE_KSTAT(rxTotalPkts, KSTAT_DATA_UINT64); QEDE_KSTAT(rxTotalBytes, KSTAT_DATA_UINT64); QEDE_KSTAT(rxTotalDiscards, KSTAT_DATA_UINT64); + QEDE_KSTAT(allocbFailures, KSTAT_DATA_UINT64); qede->kstats->ks_update = qede_kstat_update; qede->kstats->ks_private = (void *)qede; @@ -892,229 +978,221 @@ boolean_t qede_kstat_init(qede_t *qede) /****************************************************************/ if ((qede->kstats_link = kstat_create("qede", - qede->instance, - "link", - "net", - KSTAT_TYPE_NAMED, - QEDE_KSTAT_LINK_SIZE, - 0)) == NULL) - { - /*BnxeLogWarn(qede, "Failed to create link kstat");*/ - cmn_err(CE_WARN, "Failed to create link kstat"); - qede_kstat_fini(qede); - return B_FALSE; - } - - pStatsLink = (qede_kstat_link_t *)qede->kstats_link->ks_data; - - QEDE_KSTAT_LINK(vportID, KSTAT_DATA_UINT64); - QEDE_KSTAT_LINK(uptime, KSTAT_DATA_UINT64); - QEDE_KSTAT_LINK(mtuL2, KSTAT_DATA_UINT64); - QEDE_KSTAT_LINK(speed, KSTAT_DATA_UINT64); - QEDE_KSTAT_LINK(link, KSTAT_DATA_UINT64); - QEDE_KSTAT_LINK(duplex, KSTAT_DATA_UINT64); - QEDE_KSTAT_LINK(pauseRx, KSTAT_DATA_UINT64); - QEDE_KSTAT_LINK(pauseTx, KSTAT_DATA_UINT64); - - qede->kstats_link->ks_update = qede_kstat_link_update; - qede->kstats_link->ks_private = (void *)qede; - - kstat_install(qede->kstats_link); - - /****************************************************************/ + qede->instance, + "link", + "net", + KSTAT_TYPE_NAMED, + QEDE_KSTAT_LINK_SIZE, + 0)) == NULL) { + /*BnxeLogWarn(qede, "Failed to create link kstat");*/ + cmn_err(CE_WARN, "Failed to create link kstat"); + qede_kstat_fini(qede); + return (B_FALSE); + } + + pStatsLink = (qede_kstat_link_t *)qede->kstats_link->ks_data; + + QEDE_KSTAT_LINK(vportID, KSTAT_DATA_UINT64); + QEDE_KSTAT_LINK(uptime, KSTAT_DATA_UINT64); + QEDE_KSTAT_LINK(mtuL2, KSTAT_DATA_UINT64); + QEDE_KSTAT_LINK(speed, KSTAT_DATA_UINT64); + QEDE_KSTAT_LINK(link, KSTAT_DATA_UINT64); + QEDE_KSTAT_LINK(duplex, KSTAT_DATA_UINT64); + QEDE_KSTAT_LINK(pauseRx, KSTAT_DATA_UINT64); + QEDE_KSTAT_LINK(pauseTx, KSTAT_DATA_UINT64); + + qede->kstats_link->ks_update = qede_kstat_link_update; + qede->kstats_link->ks_private = (void *)qede; + + kstat_install(qede->kstats_link); + + /****************************************************************/ if ((qede->kstats_intr = kstat_create("qede", - qede->instance, - "intr", - "net", - KSTAT_TYPE_NAMED, - QEDE_KSTAT_INTR_SIZE, - 0)) == NULL) - { - /*BnxeLogWarn(qede, "Failed to create intr kstat");*/ - cmn_err(CE_WARN, "Failed to create intr kstat"); - qede_kstat_fini(qede); - return B_FALSE; - } + qede->instance, + "intr", + "net", + KSTAT_TYPE_NAMED, + QEDE_KSTAT_INTR_SIZE, + 0)) == NULL) { + /*BnxeLogWarn(qede, "Failed to create intr kstat");*/ + cmn_err(CE_WARN, "Failed to create intr kstat"); + qede_kstat_fini(qede); + return (B_FALSE); + } pStatsIntr = (qede_kstat_intr_t *)qede->kstats_intr->ks_data; - QEDE_KSTAT_INTR(intrAlloc, KSTAT_DATA_CHAR); - QEDE_KSTAT_INTR(intrFired, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_00, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_01, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_02, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_03, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_04, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_05, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_06, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_nc_00, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_nc_01, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_nc_02, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_nc_03, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_nc_04, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_nc_05, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_nc_06, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_00, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_01, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_02, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_03, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_04, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_05, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_06, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_nc_00, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_nc_01, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_nc_02, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_nc_03, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_nc_04, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_nc_05, KSTAT_DATA_UINT64); - QEDE_KSTAT_INTR(sb_poll_nc_06, KSTAT_DATA_UINT64); - - qede->kstats_intr->ks_update = qede_kstat_intr_update; - qede->kstats_intr->ks_private = (void *)qede; - - kstat_install(qede->kstats_intr); + QEDE_KSTAT_INTR(intrAlloc, KSTAT_DATA_CHAR); + QEDE_KSTAT_INTR(intrFired, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_00, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_01, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_02, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_03, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_04, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_05, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_06, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_nc_00, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_nc_01, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_nc_02, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_nc_03, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_nc_04, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_nc_05, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_nc_06, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_00, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_01, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_02, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_03, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_04, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_05, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_06, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_nc_00, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_nc_01, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_nc_02, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_nc_03, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_nc_04, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_nc_05, KSTAT_DATA_UINT64); + QEDE_KSTAT_INTR(sb_poll_nc_06, KSTAT_DATA_UINT64); + + qede->kstats_intr->ks_update = qede_kstat_intr_update; + qede->kstats_intr->ks_private = (void *)qede; + + kstat_install(qede->kstats_intr); /****************************************************************/ - if ((qede->kstats_vport = kstat_create("qede", - qede->instance, - "L2Stats", - "net", - KSTAT_TYPE_NAMED, - QEDE_KSTAT_VPORT_STATS_SIZE, - 0)) == NULL) - { - /*BnxeLogWarn(qede, "Failed to create l2chip kstat");*/ - cmn_err(CE_WARN, "Failed to create L2Stats kstat"); - qede_kstat_fini(qede); - return B_FALSE; - } - - pStatsVport = (qede_kstat_vport_stats_t *)qede->kstats_vport->ks_data; - - QEDE_KSTAT_VPORT(rxUcastBytes, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxMcastBytes, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxBcastBytes, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxUcastPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxMcastPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxBcastPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txUcastBytes, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txMcastBytes, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txBcastBytes, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txUcastPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txMcastPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txBcastPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx64bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx127bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx255bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx511bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx1023bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx1518bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx1518bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx1522bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx2047bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx4095bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx9216bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rx16383bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx64bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx64to127bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx128to255bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx256to511bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx512to1023bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx1024to1518bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx1519to2047bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx2048to4095bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx4096to9216bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(tx9217to16383bytePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxMacCtrlFrames, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxPauseFrames, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txPauseFrames, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxCRCerrors, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxAlignErrors, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxCarrierErrors, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxOversizeErrors, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxJabbers, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxUndersizePkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(rxFragments, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txLpiEntryCnt, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txTotalCollisions, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(brbTruncates, KSTAT_DATA_UINT64); - - QEDE_KSTAT_VPORT(noBuffDiscards, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(mftagFilterDiscards, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(macFilterDiscards, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(txErrDropPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(coalescedPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(coalescedEvents, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(coalescedAbortsNum, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(nonCoalescedPkts, KSTAT_DATA_UINT64); - QEDE_KSTAT_VPORT(coalescedBytes, KSTAT_DATA_UINT64); - - qede->kstats_vport->ks_update = qede_kstat_vport_stats_update; - qede->kstats_vport->ks_private = (void *)qede; - - kstat_install(qede->kstats_vport); - for (i = 0; i < qede->num_fp; i++) { - if(!qede_kstat_init_rxq(qede,i)) - { - qede_kstat_fini(qede); - return B_FALSE; - } - if(!qede_kstat_init_txq(qede,i)) - { + if ((qede->kstats_vport = kstat_create("qede", + qede->instance, + "L2Stats", + "net", + KSTAT_TYPE_NAMED, + QEDE_KSTAT_VPORT_STATS_SIZE, + 0)) == NULL) { + /*BnxeLogWarn(qede, "Failed to create l2chip kstat");*/ + cmn_err(CE_WARN, "Failed to create L2Stats kstat"); qede_kstat_fini(qede); - return B_FALSE; + return (B_FALSE); } + + pStatsVport = (qede_kstat_vport_stats_t *)qede->kstats_vport->ks_data; + + QEDE_KSTAT_VPORT(rxUcastBytes, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxMcastBytes, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxBcastBytes, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxUcastPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxMcastPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxBcastPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txUcastBytes, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txMcastBytes, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txBcastBytes, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txUcastPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txMcastPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txBcastPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx64bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx127bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx255bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx511bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx1023bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx1518bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx1518bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx1522bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx2047bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx4095bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx9216bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rx16383bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx64bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx64to127bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx128to255bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx256to511bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx512to1023bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx1024to1518bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx1519to2047bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx2048to4095bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx4096to9216bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(tx9217to16383bytePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxMacCtrlFrames, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxPauseFrames, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txPauseFrames, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxCRCerrors, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxAlignErrors, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxCarrierErrors, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxOversizeErrors, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxJabbers, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxUndersizePkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(rxFragments, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txLpiEntryCnt, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txTotalCollisions, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(brbTruncates, KSTAT_DATA_UINT64); + + QEDE_KSTAT_VPORT(noBuffDiscards, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(mftagFilterDiscards, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(macFilterDiscards, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(txErrDropPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(coalescedPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(coalescedEvents, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(coalescedAbortsNum, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(nonCoalescedPkts, KSTAT_DATA_UINT64); + QEDE_KSTAT_VPORT(coalescedBytes, KSTAT_DATA_UINT64); + + qede->kstats_vport->ks_update = qede_kstat_vport_stats_update; + qede->kstats_vport->ks_private = (void *)qede; + + kstat_install(qede->kstats_vport); + for (i = 0; i < qede->num_fp; i++) { + if(!qede_kstat_init_rxq(qede,i)) + { + qede_kstat_fini(qede); + return (B_FALSE); + } + if(!qede_kstat_init_txq(qede,i)) + { + qede_kstat_fini(qede); + return (B_FALSE); + } } -return B_TRUE; + return (B_TRUE); } -void qede_kstat_fini(qede_t *qede) +void +qede_kstat_fini(qede_t *qede) { int i; - if(qede->kstats) - { + if(qede->kstats) { kstat_delete(qede->kstats); qede->kstats = NULL; } - if(qede->kstats_link) - { + if(qede->kstats_link) { kstat_delete(qede->kstats_link); qede->kstats_link = NULL; } - if(qede->kstats_intr) - { + if(qede->kstats_intr) { kstat_delete(qede->kstats_intr); qede->kstats_intr = NULL; } - if(qede->kstats_vport) - { + if(qede->kstats_vport) { kstat_delete(qede->kstats_vport); qede->kstats_vport = NULL; } - for (i = 0; i < qede->num_fp; i++) { - if(qede->kstats_rxq[i]) - { - kstat_delete(qede->kstats_rxq[i]); - qede->kstats_rxq[i] = NULL; - } - qede->kstats_rxq_map[i].idx = 0; - qede->kstats_rxq_map[i].qede = NULL; - if(qede->kstats_txq[i]) - { - kstat_delete(qede->kstats_txq[i]); - qede->kstats_txq[i] = NULL; + for (i = 0; i < qede->num_fp; i++) { + if(qede->kstats_rxq[i]) { + kstat_delete(qede->kstats_rxq[i]); + qede->kstats_rxq[i] = NULL; + } + qede->kstats_rxq_map[i].idx = 0; + qede->kstats_rxq_map[i].qede = NULL; + if(qede->kstats_txq[i]) { + kstat_delete(qede->kstats_txq[i]); + qede->kstats_txq[i] = NULL; + } + qede->kstats_txq_map[i].idx = 0; + qede->kstats_txq_map[i].qede = NULL; } - qede->kstats_txq_map[i].idx = 0; - qede->kstats_txq_map[i].qede = NULL; - } } diff --git a/usr/src/uts/common/io/qede/qede_list.h b/usr/src/uts/common/io/qede/qede_list.h index 0169182137..656d2a915f 100644 --- a/usr/src/uts/common/io/qede/qede_list.h +++ b/usr/src/uts/common/io/qede/qede_list.h @@ -33,14 +33,16 @@ * limitations under the License. */ +#ifndef _QEDE_LIST_H +#define _QEDE_LIST_H typedef struct qede_list_s { - struct qede_list_s *next; - struct qede_list_s *prev; + struct qede_list_s *next; + struct qede_list_s *prev; }qede_list_t; typedef struct qede_mem_list_entry { - void *buf; + void *buf; size_t size; qede_list_t mem_entry; } qede_mem_list_entry_t; @@ -55,8 +57,8 @@ typedef struct phys_mem_entry { ddi_dma_handle_t dma_handle; ddi_acc_handle_t dma_acc_handle; size_t size; - void *virt_addr; - void *paddr; + void *virt_addr; + void *paddr; } qede_phys_mem_entry_t; typedef struct qede_phys_mem_list { @@ -79,7 +81,8 @@ typedef qede_list_t osal_list_entry_t; /* * Linked list helpers */ -static inline void QEDE_INIT_LIST_HEAD(qede_list_t *list) +static inline void +QEDE_INIT_LIST_HEAD(qede_list_t *list) { list->next = list; list->prev = list; @@ -87,7 +90,8 @@ static inline void QEDE_INIT_LIST_HEAD(qede_list_t *list) #define OSAL_LIST_INIT(_list_) QEDE_INIT_LIST_HEAD(_list_) -static inline void qede_list_add(qede_list_t *new, +static inline void +qede_list_add(qede_list_t *new, qede_list_t *prev, qede_list_t *next) { @@ -97,33 +101,39 @@ static inline void qede_list_add(qede_list_t *new, prev->next = new; } -static inline bool qede_list_empty(qede_list_t *entry) +static inline bool +qede_list_empty(qede_list_t *entry) { return (entry->next == entry); } -static inline void qede_list_del(qede_list_t *prev, qede_list_t *next) +static inline void +qede_list_del(qede_list_t *prev, qede_list_t *next) { next->prev = prev; prev->next = next; } -static inline void QEDE_LIST_ADD(qede_list_t *new, qede_list_t *head) +static inline void +QEDE_LIST_ADD(qede_list_t *new, qede_list_t *head) { qede_list_add(new, head, head->next); } -static inline void QEDE_LIST_ADD_TAIL(qede_list_t *new, qede_list_t *head) +static inline void +QEDE_LIST_ADD_TAIL(qede_list_t *new, qede_list_t *head) { qede_list_add(new, head->prev, head); } -static inline void QEDE_LIST_REMOVE(qede_list_t *entry, qede_list_t *head) +static inline void +QEDE_LIST_REMOVE(qede_list_t *entry, qede_list_t *head) { qede_list_del(entry->prev, entry->next); } -static inline void list_splice(const qede_list_t *list, +static inline void +list_splice(const qede_list_t *list, qede_list_t *prev, qede_list_t *next) { @@ -137,14 +147,17 @@ static inline void list_splice(const qede_list_t *list, next->prev = last; } -static inline void qede_list_splice(qede_list_t *list, +static inline void +qede_list_splice(qede_list_t *list, qede_list_t *head) { - if (!qede_list_empty(list)) + if (!qede_list_empty(list)) { list_splice(list, head, head->next); + } } -static inline void qede_list_splice_tail(qede_list_t *list, +static inline void +qede_list_splice_tail(qede_list_t *list, qede_list_t *head) { if (!qede_list_empty(list)) { @@ -161,3 +174,5 @@ static inline void qede_list_splice_tail(qede_list_t *list, #define QEDE_LIST_FOR_EACH_ENTRY(_entry_, _list_, _type_, _member_) \ OSAL_LIST_FOR_EACH_ENTRY(_entry_, _list_, _member_, _type_) #define QEDE_LIST_FOR_EACH_ENTRY_SAFE OSAL_LIST_FOR_EACH_ENTRY_SAFE + +#endif /* !_QEDE_LIST_H */ diff --git a/usr/src/uts/common/io/qede/qede_main.c b/usr/src/uts/common/io/qede/qede_main.c index 5dda61dfbb..0ebd3e45c9 100644 --- a/usr/src/uts/common/io/qede/qede_main.c +++ b/usr/src/uts/common/io/qede/qede_main.c @@ -37,29 +37,31 @@ #include "qede.h" ddi_device_acc_attr_t qede_regs_acc_attr = { - DDI_DEVICE_ATTR_V1, // devacc_attr_version; - DDI_STRUCTURE_LE_ACC, // devacc_attr_endian_flags; - DDI_STRICTORDER_ACC, // devacc_attr_dataorder; - DDI_FLAGERR_ACC // devacc_attr_access; + DDI_DEVICE_ATTR_V1, // devacc_attr_version; + DDI_STRUCTURE_LE_ACC, // devacc_attr_endian_flags; + DDI_STRICTORDER_ACC, // devacc_attr_dataorder; + DDI_FLAGERR_ACC // devacc_attr_access; }; ddi_device_acc_attr_t qede_desc_acc_attr = { - DDI_DEVICE_ATTR_V0, // devacc_attr_version; - DDI_STRUCTURE_LE_ACC, // devacc_attr_endian_flags; - DDI_STRICTORDER_ACC // devacc_attr_dataorder; + DDI_DEVICE_ATTR_V0, // devacc_attr_version; + DDI_STRUCTURE_LE_ACC, // devacc_attr_endian_flags; + DDI_STRICTORDER_ACC // devacc_attr_dataorder; }; /* * DMA access attributes for BUFFERS. */ -ddi_device_acc_attr_t qede_buf_acc_attr = { - DDI_DEVICE_ATTR_V0, // devacc_attr_version; - DDI_NEVERSWAP_ACC, // devacc_attr_endian_flags; - DDI_STRICTORDER_ACC // devacc_attr_dataorder; +ddi_device_acc_attr_t qede_buf_acc_attr = +{ + DDI_DEVICE_ATTR_V0, // devacc_attr_version; + DDI_NEVERSWAP_ACC, // devacc_attr_endian_flags; + DDI_STRICTORDER_ACC // devacc_attr_dataorder; }; -ddi_dma_attr_t qede_desc_dma_attr = { +ddi_dma_attr_t qede_desc_dma_attr = +{ DMA_ATTR_V0, 0x0000000000000000ull, 0xFFFFFFFFFFFFFFFFull, @@ -74,7 +76,8 @@ ddi_dma_attr_t qede_desc_dma_attr = { DDI_DMA_FLAGERR }; -ddi_dma_attr_t qede_gen_buf_dma_attr = { +ddi_dma_attr_t qede_gen_buf_dma_attr = +{ DMA_ATTR_V0, 0x0000000000000000ull, 0xFFFFFFFFFFFFFFFFull, @@ -92,7 +95,8 @@ ddi_dma_attr_t qede_gen_buf_dma_attr = { /* * DMA attributes for transmit. */ -ddi_dma_attr_t qede_tx_buf_dma_attr = { +ddi_dma_attr_t qede_tx_buf_dma_attr = +{ DMA_ATTR_V0, 0x0000000000000000ull, 0xFFFFFFFFFFFFFFFFull, @@ -108,7 +112,8 @@ ddi_dma_attr_t qede_tx_buf_dma_attr = { }; -ddi_dma_attr_t qede_dma_attr_desc = { +ddi_dma_attr_t qede_dma_attr_desc = +{ DMA_ATTR_V0, /* dma_attr_version */ 0, /* dma_attr_addr_lo */ 0xffffffffffffffffull, /* dma_attr_addr_hi */ @@ -123,7 +128,8 @@ ddi_dma_attr_t qede_dma_attr_desc = { DDI_DMA_FLAGERR /* dma_attr_flags */ }; -static ddi_dma_attr_t qede_dma_attr_txbuf = { +static ddi_dma_attr_t qede_dma_attr_txbuf = +{ DMA_ATTR_V0, /* dma_attr_version */ 0, /* dma_attr_addr_lo */ 0xffffffffffffffffull, /* dma_attr_addr_hi */ @@ -138,7 +144,8 @@ static ddi_dma_attr_t qede_dma_attr_txbuf = { 0 /* dma_attr_flags */ }; -ddi_dma_attr_t qede_dma_attr_rxbuf = { +ddi_dma_attr_t qede_dma_attr_rxbuf = +{ DMA_ATTR_V0, /* dma_attr_version */ 0, /* dma_attr_addr_lo */ 0xffffffffffffffffull, /* dma_attr_addr_hi */ @@ -153,7 +160,9 @@ ddi_dma_attr_t qede_dma_attr_rxbuf = { DDI_DMA_RELAXED_ORDERING /* dma_attr_flags */ }; -static ddi_dma_attr_t qede_dma_attr_cmddesc = { +/* LINTED E_STATIC_UNUSED */ +static ddi_dma_attr_t qede_dma_attr_cmddesc = +{ DMA_ATTR_V0, /* dma_attr_version */ 0, /* dma_attr_addr_lo */ 0xffffffffffffffffull, /* dma_attr_addr_hi */ @@ -173,22 +182,25 @@ static ddi_dma_attr_t qede_dma_attr_cmddesc = { /* * Generic dma attribute for single sg */ -static ddi_dma_attr_t qede_gen_dma_attr_desc = { - DMA_ATTR_V0, /* dma_attr_version */ - 0, /* dma_attr_addr_lo */ +/* LINTED E_STATIC_UNUSED */ +static ddi_dma_attr_t qede_gen_dma_attr_desc = +{ + DMA_ATTR_V0, /* dma_attr_version */ + 0, /* dma_attr_addr_lo */ 0xffffffffffffffffull, /* dma_attr_addr_hi */ - 0x000fffffull, /* dma_attr_count_max */ - 4096, /* dma_attr_align */ - 0x000fffffull, /* dma_attr_burstsizes */ - 4, /* dma_attr_minxfer */ - 0xffffffffull, /* dma_attr_maxxfer */ - 0xffffffffull, /* dma_attr_seg */ - 1, /* dma_attr_sgllen */ - 1, /* dma_attr_granular */ - DDI_DMA_FLAGERR /* dma_attr_flags */ + 0x000fffffull, /* dma_attr_count_max */ + 4096, /* dma_attr_align */ + 0x000fffffull, /* dma_attr_burstsizes */ + 4, /* dma_attr_minxfer */ + 0xffffffffull, /* dma_attr_maxxfer */ + 0xffffffffull, /* dma_attr_seg */ + 1, /* dma_attr_sgllen */ + 1, /* dma_attr_granular */ + DDI_DMA_FLAGERR /* dma_attr_flags */ }; -ddi_dma_attr_t qede_buf2k_dma_attr_txbuf = { +ddi_dma_attr_t qede_buf2k_dma_attr_txbuf = +{ DMA_ATTR_V0, /* dma_attr_version */ 0, /* dma_attr_addr_lo */ 0xffffffffffffffffull, /* dma_attr_addr_hi */ @@ -203,88 +215,104 @@ ddi_dma_attr_t qede_buf2k_dma_attr_txbuf = { 0 /* dma_attr_flags */ }; -char *qede_get_ddi_fail(int status) +char * +qede_get_ddi_fail(int status) { - switch(status) - { + switch (status) { case DDI_FAILURE: - return("DDI_FAILURE"); + return ("DDI_FAILURE"); case DDI_NOT_WELL_FORMED: - return("DDI_NOT_WELL_FORMED"); + return ("DDI_NOT_WELL_FORMED"); case DDI_EAGAIN: - return("DDI_EAGAIN"); + return ("DDI_EAGAIN"); case DDI_EINVAL: - return("DDI_EINVAL"); + return ("DDI_EINVAL"); case DDI_ENOTSUP: - return("DDI_ENOTSUP"); + return ("DDI_ENOTSUP"); case DDI_EPENDING: - return("DDI_EPENDING"); + return ("DDI_EPENDING"); case DDI_EALREADY: - return("DDI_EALREADY"); + return ("DDI_EALREADY"); case DDI_ENOMEM: - return("DDI_ENOMEM"); + return ("DDI_ENOMEM"); case DDI_EBUSY: - return("DDI_EBUSY"); + return ("DDI_EBUSY"); case DDI_ETRANSPORT: - return("DDI_ETRANSPORT"); + return ("DDI_ETRANSPORT"); case DDI_ECONTEXT: - return("DDI_ECONTEXT"); + return ("DDI_ECONTEXT"); default: - return("ERROR CODE NOT FOUND!"); + return ("ERROR CODE NOT FOUND!"); } } -char *qede_get_ecore_fail(int status) +char * +qede_get_ecore_fail(int status) { - switch(status) - { + switch (status) { case ECORE_UNKNOWN_ERROR: - return("ECORE_UNKNOWN_ERROR"); + return ("ECORE_UNKNOWN_ERROR"); case ECORE_NORESOURCES: - return("ECORE_NORESOURCES"); + return ("ECORE_NORESOURCES"); case ECORE_NODEV: - return("ECORE_NODEV"); + return ("ECORE_NODEV"); case ECORE_ABORTED: - return("ECORE_ABORTED"); + return ("ECORE_ABORTED"); case ECORE_AGAIN: - return("ECORE_AGAIN"); + return ("ECORE_AGAIN"); case ECORE_NOTIMPL: - return("ECORE_NOTIMPL"); + return ("ECORE_NOTIMPL"); case ECORE_EXISTS: - return("ECORE_EXISTS"); + return ("ECORE_EXISTS"); case ECORE_IO: - return("ECORE_IO"); + return ("ECORE_IO"); case ECORE_TIMEOUT: - return("ECORE_TIMEOUT"); + return ("ECORE_TIMEOUT"); case ECORE_INVAL: - return("ECORE_INVAL"); + return ("ECORE_INVAL"); case ECORE_BUSY: - return("ECORE_BUSY"); + return ("ECORE_BUSY"); case ECORE_NOMEM: - return("ECORE_NOMEM"); + return ("ECORE_NOMEM"); case ECORE_SUCCESS: - return("ECORE_SUCCESS"); + return ("ECORE_SUCCESS"); case ECORE_PENDING: - return("ECORE_PENDING"); + return ("ECORE_PENDING"); default: - return("ECORE ERROR CODE NOT FOUND!"); + return ("ECORE ERROR CODE NOT FOUND!"); } } -#define QEDE_CHIP_NUM(_p) (((_p)->edev.chip_num) & 0xffff) +#define QEDE_CHIP_NUM(_p)\ + (((_p)->edev.chip_num) & 0xffff) -char * qede_chip_name(qede_t * qede) +char * +qede_chip_name(qede_t *qede) { - switch (QEDE_CHIP_NUM(qede)) - { - case 0x1634: return "BCM57980E"; - case 0x1629: return "BCM57980S"; - case 0x1630: return "BCM57940_KR2"; - case 0x8070: return "ARROWHEAD"; - case 0x8071: return "ARROWHEAD"; - case 0x8072: return "ARROWHEAD"; - case 0x8073: return "ARROWHEAD"; - default: return "UNKNOWN"; + switch (QEDE_CHIP_NUM(qede)) { + case 0x1634: + return ("BCM57980E"); + + case 0x1629: + return ("BCM57980S"); + + case 0x1630: + return ("BCM57940_KR2"); + + case 0x8070: + return ("ARROWHEAD"); + + case 0x8071: + return ("ARROWHEAD"); + + case 0x8072: + return ("ARROWHEAD"); + + case 0x8073: + return ("ARROWHEAD"); + + default: + return ("UNKNOWN"); } } @@ -294,11 +322,10 @@ char * qede_chip_name(qede_t * qede) static void qede_destroy_locks(qede_t *qede) { - qede_intr_context_t *intr_ctx = &qede->intr_ctx; qede_fastpath_t *fp = &qede->fp_array[0]; qede_rx_ring_t *rx_ring; qede_tx_ring_t *tx_ring; - int i,j; + int i, j; mutex_destroy(&qede->drv_lock); mutex_destroy(&qede->watch_lock); @@ -309,7 +336,6 @@ qede_destroy_locks(qede_t *qede) rx_ring = fp->rx_ring; mutex_destroy(&rx_ring->rx_lock); mutex_destroy(&rx_ring->rx_replen_lock); - //mutex_destroy(&rx_ring->rx_buf_area->rx_buf_area_lock); for (j = 0; j < qede->num_tc; j++) { tx_ring = fp->tx_ring[j]; @@ -343,8 +369,6 @@ qede_init_locks(qede_t *qede) MUTEX_DRIVER, DDI_INTR_PRI(intr_ctx->intr_pri)); mutex_init(&rx_ring->rx_replen_lock, NULL, MUTEX_DRIVER, DDI_INTR_PRI(intr_ctx->intr_pri)); - //mutex_init(&rx_ring->rx_buf_area->rx_buf_area_lock, NULL, - // MUTEX_DRIVER, DDI_INTR_PRI(intr_ctx->intr_pri)); for (tc = 0; tc < qede->num_tc; tc++) { tx_ring = fp->tx_ring[tc]; @@ -359,16 +383,14 @@ qede_init_locks(qede_t *qede) MUTEX_DRIVER, DDI_INTR_PRI(intr_ctx->intr_pri)); } -static void -qede_free_io_structs(qede_t *qede) +/* LINTED E_FUNC_ARG_UNUSED */ +static void qede_free_io_structs(qede_t *qede) { - return; } static int qede_alloc_io_structs(qede_t *qede) { - int vector_count; qede_fastpath_t *fp; qede_rx_ring_t *rx_ring; qede_tx_ring_t *tx_array, *tx_ring; @@ -392,7 +414,7 @@ qede_alloc_io_structs(qede_t *qede) rx_ring->group_index = 0; } - return(DDI_SUCCESS); + return (DDI_SUCCESS); } static int @@ -406,27 +428,42 @@ qede_get_config_params(qede_t *qede) qede->num_hwfns = edev->num_hwfns; qede->rx_buf_count = qede->rx_ring_size; qede->rx_buf_size = DEFAULT_RX_BUF_SIZE; - qede_print("!%s:%d: qede->num_fp = %d\n", __func__, qede->instance, qede->num_fp); - qede_print("!%s:%d: qede->rx_ring_size = %d\n", __func__, qede->instance, qede->rx_ring_size); - qede_print("!%s:%d: qede->rx_buf_count = %d\n", __func__, qede->instance, qede->rx_buf_count); - qede_print("!%s:%d: qede->rx_buf_size = %d\n", __func__, qede->instance, qede->rx_buf_size); - qede_print("!%s:%d: qede->rx_copy_threshold = %d\n", __func__, qede->instance, qede->rx_copy_threshold); - qede_print("!%s:%d: qede->tx_ring_size = %d\n", __func__, qede->instance, qede->tx_ring_size); - qede_print("!%s:%d: qede->tx_copy_threshold = %d\n", __func__, qede->instance, qede->tx_bcopy_threshold); - qede_print("!%s:%d: qede->lso_enable = %d\n", __func__, qede->instance, qede->lso_enable); - qede_print("!%s:%d: qede->lro_enable = %d\n", __func__, qede->instance, qede->lro_enable); - qede_print("!%s:%d: qede->jumbo_enable = %d\n", __func__, qede->instance, qede->jumbo_enable); - qede_print("!%s:%d: qede->log_enable = %d\n", __func__, qede->instance, qede->log_enable); - qede_print("!%s:%d: qede->checksum = %d\n", __func__, qede->instance, qede->checksum); - qede_print("!%s:%d: qede->debug_level = 0x%x\n", __func__, qede->instance, qede->ecore_debug_level); - qede_print("!%s:%d: qede->num_hwfns = %d\n", __func__, qede->instance,qede->num_hwfns); + qede_print("!%s:%d: qede->num_fp = %d\n", __func__, qede->instance, + qede->num_fp); + qede_print("!%s:%d: qede->rx_ring_size = %d\n", __func__, + qede->instance, qede->rx_ring_size); + qede_print("!%s:%d: qede->rx_buf_count = %d\n", __func__, + qede->instance, qede->rx_buf_count); + qede_print("!%s:%d: qede->rx_buf_size = %d\n", __func__, + qede->instance, qede->rx_buf_size); + qede_print("!%s:%d: qede->rx_copy_threshold = %d\n", __func__, + qede->instance, qede->rx_copy_threshold); + qede_print("!%s:%d: qede->tx_ring_size = %d\n", __func__, + qede->instance, qede->tx_ring_size); + qede_print("!%s:%d: qede->tx_copy_threshold = %d\n", __func__, + qede->instance, qede->tx_bcopy_threshold); + qede_print("!%s:%d: qede->lso_enable = %d\n", __func__, + qede->instance, qede->lso_enable); + qede_print("!%s:%d: qede->lro_enable = %d\n", __func__, + qede->instance, qede->lro_enable); + qede_print("!%s:%d: qede->jumbo_enable = %d\n", __func__, + qede->instance, qede->jumbo_enable); + qede_print("!%s:%d: qede->log_enable = %d\n", __func__, + qede->instance, qede->log_enable); + qede_print("!%s:%d: qede->checksum = %d\n", __func__, + qede->instance, qede->checksum); + qede_print("!%s:%d: qede->debug_level = 0x%x\n", __func__, + qede->instance, qede->ecore_debug_level); + qede_print("!%s:%d: qede->num_hwfns = %d\n", __func__, + qede->instance,qede->num_hwfns); //qede->tx_buf_size = qede->mtu + QEDE_MAX_ETHER_HDR; qede->tx_buf_size = BUF_2K_SIZE; return (DDI_SUCCESS); } -void qede_config_debug(qede_t * qede) +void +qede_config_debug(qede_t *qede) { struct ecore_dev *edev = &qede->edev; @@ -448,8 +485,9 @@ qede_set_operating_params(qede_t *qede) /* Get qede.conf paramters from user */ status = qede_get_config_params(qede); - if (status != DDI_SUCCESS) + if (status != DDI_SUCCESS) { return (DDI_FAILURE); + } /* config debug level */ qede_config_debug(qede); @@ -461,13 +499,13 @@ qede_set_operating_params(qede_t *qede) /* set max number of Unicast list */ qede->ucst_total = QEDE_MAX_UCST_CNT; qede->ucst_avail = QEDE_MAX_UCST_CNT; - bzero(&qede->ucst_mac[0], sizeof(qede_mac_addr_t) * qede->ucst_total); + bzero(&qede->ucst_mac[0], sizeof (qede_mac_addr_t) * qede->ucst_total); qede->params.multi_promisc_fl = B_FALSE; qede->params.promisc_fl = B_FALSE; qede->mc_cnt = 0; qede->rx_low_buffer_threshold = RX_LOW_BUFFER_THRESHOLD; - return(status); + return (status); } /* Resume the interface */ @@ -515,14 +553,11 @@ static int qede_config_pci(qede_t *qede) { int ret; - off_t regsize; - struct ecore_dev *edev; - - edev = &qede->edev; ret = pci_config_setup(qede->dip, &qede->pci_cfg_handle); if (ret != DDI_SUCCESS) { - cmn_err(CE_NOTE, "%s:%d Failed to get PCI config handle\n", __func__, qede->instance); + cmn_err(CE_NOTE, "%s:%d Failed to get PCI config handle\n", + __func__, qede->instance); return (DDI_FAILURE); } @@ -606,16 +641,17 @@ err_exit: return (DDI_FAILURE); } -//typedef uint_t (ddi_intr_handler_t)(caddr_t arg1, caddr_t arg2); static uint_t qede_sp_handler(caddr_t arg1, caddr_t arg2) { + /*LINTED E_BAD_PTR_CAST_ALIGN*/ struct ecore_hwfn *p_hwfn = (struct ecore_hwfn *)arg1; + /* LINTED E_BAD_PTR_CAST_ALIGN */ qede_vector_info_t *vect_info = (qede_vector_info_t *)arg2; struct ecore_dev *edev = p_hwfn->p_dev; - qede_t * qede = (qede_t *)edev; + qede_t *qede = (qede_t *)edev; - if (arg1 == NULL || arg2 == NULL) { + if ((arg1 == NULL) || (arg2 == NULL)) { cmn_err(CE_WARN, "qede_sp_handler: invalid parameters"); /* * MSIX intr should always @@ -656,14 +692,16 @@ qede_disable_hw_intr(qede_fastpath_t *fp) static uint_t qede_fp_handler(caddr_t arg1, caddr_t arg2) { - qede_vector_info_t *vect_info = (qede_vector_info_t *)arg1;; + /* LINTED E_BAD_PTR_CAST_ALIGN */ + qede_vector_info_t *vect_info = (qede_vector_info_t *)arg1; + /* LINTED E_BAD_PTR_CAST_ALIGN */ qede_t *qede = (qede_t *)arg2; qede_fastpath_t *fp; qede_rx_ring_t *rx_ring; mblk_t *mp; int work_done = 0; - if (vect_info == NULL || vect_info->fp == NULL) { + if ((vect_info == NULL) || (vect_info->fp == NULL)) { cmn_err(CE_WARN, "qede_fp_handler: invalid parameters"); return (DDI_INTR_UNCLAIMED); } @@ -685,15 +723,20 @@ qede_fp_handler(caddr_t arg1, caddr_t arg2) if (mp) #ifndef NO_CROSSBOW + { mac_rx_ring(rx_ring->qede->mac_handle, rx_ring->mac_ring_handle, mp, rx_ring->mr_gen_num); + } #else + { mac_rx(qede->mac_handle, NULL, mp); + } #endif - else if(!mp && (work_done == 0)) + else if (!mp && (work_done == 0)) { qede->intrSbNoChangeCnt[vect_info->vect_index]++; + } mutex_enter(&fp->qede->drv_lock); @@ -704,13 +747,14 @@ qede_fp_handler(caddr_t arg1, caddr_t arg2) * In this case we do not want to * enable them here. */ - if (fp->disabled_by_poll == 0) + if (fp->disabled_by_poll == 0) { qede_enable_hw_intr(fp); + } mutex_exit(&fp->qede->drv_lock); mutex_exit(&fp->fp_lock); - return (work_done ? DDI_INTR_CLAIMED : DDI_INTR_UNCLAIMED); + return (work_done ? DDI_INTR_CLAIMED : DDI_INTR_UNCLAIMED); } static int @@ -722,13 +766,13 @@ qede_disable_intr(qede_t *qede, uint32_t index) status = ddi_intr_disable(intr_ctx->intr_hdl_array[index]); if (status != DDI_SUCCESS) { cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_enable with %s" - " for index %d\n", - __func__, qede_get_ddi_fail(status), index); - return(status); + " for index %d\n", + __func__, qede_get_ddi_fail(status), index); + return (status); } atomic_and_32(&intr_ctx->intr_state, ~(1 << index)); - return(status); + return (status); } static int @@ -742,14 +786,14 @@ qede_enable_intr(qede_t *qede, int index) if (status != DDI_SUCCESS) { cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_enable with %s" - " for index %d\n", - __func__, qede_get_ddi_fail(status), index); - return(status); + " for index %d\n", + __func__, qede_get_ddi_fail(status), index); + return (status); } atomic_or_32(&intr_ctx->intr_state, (1 << index)); - return(status); + return (status); } static int @@ -759,10 +803,11 @@ qede_disable_all_fastpath_intrs(qede_t *qede) for (i = qede->num_hwfns; i <= qede->num_fp; i++) { status = qede_disable_intr(qede, i); - if (status != DDI_SUCCESS) - return(status); + if (status != DDI_SUCCESS) { + return (status); + } } - return(DDI_SUCCESS); + return (DDI_SUCCESS); } static int @@ -772,10 +817,11 @@ qede_enable_all_fastpath_intrs(qede_t *qede) for (i = qede->num_hwfns; i <= qede->num_fp; i++) { status = qede_enable_intr(qede, i); - if (status != DDI_SUCCESS) - return(status); + if (status != DDI_SUCCESS) { + return (status); + } } - return(DDI_SUCCESS); + return (DDI_SUCCESS); } static int @@ -785,10 +831,11 @@ qede_disable_slowpath_intrs(qede_t *qede) for (i = 0; i < qede->num_hwfns; i++) { status = qede_disable_intr(qede, i); - if (status != DDI_SUCCESS) - return(status); + if (status != DDI_SUCCESS) { + return (status); + } } - return(DDI_SUCCESS); + return (DDI_SUCCESS); } static int @@ -798,10 +845,11 @@ qede_enable_slowpath_intrs(qede_t *qede) for (i = 0; i < qede->num_hwfns; i++) { status = qede_enable_intr(qede, i); - if (status != DDI_SUCCESS) - return(status); + if (status != DDI_SUCCESS) { + return (status); + } } - return(DDI_SUCCESS); + return (DDI_SUCCESS); } static int @@ -809,10 +857,6 @@ qede_prepare_edev(qede_t *qede) { struct ecore_dev *edev = &qede->edev; struct ecore_hw_prepare_params p_params; - int status; - u32 dp_module; - u8 dp_level; - time_t epoch; /* * Setup the bar0 and bar2 base address @@ -821,10 +865,10 @@ qede_prepare_edev(qede_t *qede) edev->regview = (void *)qede->regview; edev->doorbells = (void *)qede->doorbell; + /* LINTED E_FUNC_RET_MAYBE_IGNORED2 */ strcpy(edev->name, qede->name); ecore_init_struct(edev); - //memset((void *)p_params, 0, sizeof(struct ecore_hw_prepare_params)); p_params.personality = ECORE_PCI_ETH; p_params.drv_resc_alloc = 0; p_params.chk_reg_fifo = 1; @@ -845,17 +889,17 @@ qede_config_edev(qede_t *qede) for (i = 0; i < qede->num_hwfns; i++) { struct ecore_hwfn *p_hwfn = &edev->hwfns[i]; params = &p_hwfn->pf_params; - memset((void *)params, 0, sizeof(struct ecore_pf_params)); - //params->eth_pf_params.num_cons = 4; + memset((void *)params, 0, sizeof (struct ecore_pf_params)); params->eth_pf_params.num_cons = 32; } status = ecore_resc_alloc(edev); if (status != ECORE_SUCCESS) { - cmn_err(CE_NOTE, "%s: Could not allocate ecore resources\n", __func__); - return(DDI_ENOMEM); + cmn_err(CE_NOTE, "%s: Could not allocate ecore resources\n", + __func__); + return (DDI_ENOMEM); } ecore_resc_setup(edev); - return(DDI_SUCCESS); + return (DDI_SUCCESS); } static void @@ -868,11 +912,14 @@ qede_unconfig_intrs(qede_t *qede) for (i = 0; i < intr_ctx->intr_vect_allocated; i++) { vect_info = &intr_ctx->intr_vect_info[i]; if (intr_ctx->intr_vect_info[i].handler_added == B_TRUE) { - status = ddi_intr_remove_handler(intr_ctx->intr_hdl_array[i]); + status = ddi_intr_remove_handler( + intr_ctx->intr_hdl_array[i]); if (status != DDI_SUCCESS) { - cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_remove_handler with %s" + cmn_err(CE_WARN, "qede:%s: Failed" + " ddi_intr_remove_handler with %s" " for index %d\n", - __func__, qede_get_ddi_fail(status), i); + __func__, qede_get_ddi_fail( + status), i); } (void) ddi_intr_free(intr_ctx->intr_hdl_array[i]); @@ -889,7 +936,7 @@ qede_config_intrs(qede_t *qede) qede_intr_context_t *intr_ctx = &qede->intr_ctx; qede_vector_info_t *vect_info; struct ecore_dev *edev = &qede->edev; - int i, status = DDI_SUCCESS, fp_index = 0; + int i, status = DDI_FAILURE; ddi_intr_handler_t *handler; void *arg1, *arg2; @@ -902,7 +949,8 @@ qede_config_intrs(qede_t *qede) /* Store the table index */ vect_info->vect_index = i; vect_info->qede = qede; - /* Store the interrupt handler's argument. + /* + * Store the interrupt handler's argument. * This will be the a pointer to ecore_dev->hwfns * for slowpath, a pointer to the fastpath * structure for fastpath. @@ -913,12 +961,13 @@ qede_config_intrs(qede_t *qede) arg1 = (caddr_t)&qede->edev.hwfns[i]; arg2 = (caddr_t)vect_info; } else { - /* loop index includes hwfns + /* + * loop index includes hwfns * so they need to be subtracked * for fp_array */ vect_info->fp = - (void *)&qede->fp_array[i - qede->num_hwfns]; + (void *)&qede->fp_array[i - qede->num_hwfns]; handler = qede_fp_handler; arg1 = (caddr_t)vect_info; arg2 = (caddr_t)qede; @@ -930,20 +979,22 @@ qede_config_intrs(qede_t *qede) arg1, arg2); if (status != DDI_SUCCESS) { - cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_add_handler with %s" - " for index %d\n", - __func__, qede_get_ddi_fail(status), i); + cmn_err(CE_WARN, "qede:%s: Failed " + " ddi_intr_add_handler with %s" + " for index %d\n", + __func__, qede_get_ddi_fail( + status), i); qede_unconfig_intrs(qede); return (DDI_FAILURE); } vect_info->handler_added = B_TRUE; } - return(status); + return (status); } static void -qede_free_intrs(qede_t * qede) +qede_free_intrs(qede_t *qede) { qede_intr_context_t *intr_ctx; int i, status; @@ -955,30 +1006,37 @@ qede_free_intrs(qede_t * qede) if (intr_ctx->intr_hdl_array) { for (i = 0; i < intr_ctx->intr_vect_allocated; i++) { if (intr_ctx->intr_hdl_array[i]) { - status = ddi_intr_free(intr_ctx->intr_hdl_array[i]); - if (status != DDI_SUCCESS) - cmn_err(CE_NOTE, "qede:%s: Failed ddi_intr_free with %s\n", - __func__, qede_get_ddi_fail(status)); + status = + ddi_intr_free(intr_ctx->intr_hdl_array[i]); + if (status != DDI_SUCCESS) { + cmn_err(CE_NOTE, + "qede:%s: Failed ddi_intr_free" + " with %s\n", + __func__, + qede_get_ddi_fail(status)); + } } } intr_ctx->intr_hdl_array = NULL; } if (intr_ctx->intr_hdl_array) { - kmem_free(intr_ctx->intr_hdl_array, intr_ctx->intr_hdl_array_size); + kmem_free(intr_ctx->intr_hdl_array, + intr_ctx->intr_hdl_array_size); intr_ctx->intr_hdl_array = NULL; } if (intr_ctx->intr_vect_info) { - kmem_free(intr_ctx->intr_vect_info, intr_ctx->intr_vect_info_array_size); + kmem_free(intr_ctx->intr_vect_info, + intr_ctx->intr_vect_info_array_size); intr_ctx->intr_vect_info = NULL; } } static int -qede_alloc_intrs(qede_t * qede) +qede_alloc_intrs(qede_t *qede) { - int i, status, type_supported, num_supported; + int status, type_supported, num_supported; int actual, num_available, num_to_request; dev_info_t *dip; qede_intr_context_t *intr_ctx = &qede->intr_ctx; @@ -987,39 +1045,55 @@ qede_alloc_intrs(qede_t * qede) status = ddi_intr_get_supported_types(dip, &type_supported); if (status != DDI_SUCCESS) { - cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_get_supported_types with %s\n", - __func__, qede_get_ddi_fail(status)); - return(status); + cmn_err(CE_WARN, + "qede:%s: Failed ddi_intr_get_supported_types with %s\n", + __func__, qede_get_ddi_fail(status)); + return (status); } intr_ctx->intr_types_available = type_supported; if (type_supported & DDI_INTR_TYPE_MSIX) { intr_ctx->intr_type_in_use = DDI_INTR_TYPE_MSIX; - /* get the total number of vectors supported by the device */ - status = ddi_intr_get_nintrs(qede->dip, DDI_INTR_TYPE_MSIX, &num_supported); + /* + * get the total number of vectors + * supported by the device + */ + status = ddi_intr_get_nintrs(qede->dip, + DDI_INTR_TYPE_MSIX, &num_supported); if (status != DDI_SUCCESS) { - cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_get_nintrs with %s\n", - __func__, qede_get_ddi_fail(status)); - return(status); + cmn_err(CE_WARN, + "qede:%s: Failed ddi_intr_get_nintrs with %s\n", + __func__, qede_get_ddi_fail(status)); + return (status); } intr_ctx->intr_vect_supported = num_supported; - /* get the total number of vectors available for this instance */ - status = ddi_intr_get_navail(dip, DDI_INTR_TYPE_MSIX, &num_available); + /* + * get the total number of vectors + * available for this instance + */ + status = ddi_intr_get_navail(dip, DDI_INTR_TYPE_MSIX, + &num_available); if (status != DDI_SUCCESS) { - cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_get_navail with %s\n", - __func__, qede_get_ddi_fail(status)); + cmn_err(CE_WARN, + "qede:%s: Failed ddi_intr_get_navail with %s\n", + __func__, qede_get_ddi_fail(status)); return (status); } - if ((num_available < intr_ctx->intr_vect_to_request) && (num_available >= 2)) { + if ((num_available < intr_ctx->intr_vect_to_request) && + (num_available >= 2)) { qede->num_fp = num_available - qede->num_hwfns; - cmn_err(CE_NOTE, "qede:%s: allocated %d interrupts requested was %d\n", - __func__, num_available, intr_ctx->intr_vect_to_request); + cmn_err(CE_NOTE, + "qede:%s: allocated %d interrupts" + " requested was %d\n", + __func__, num_available, + intr_ctx->intr_vect_to_request); intr_ctx->intr_vect_to_request = num_available; } else if(num_available < 2) { - cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_get_navail with %s\n", + cmn_err(CE_WARN, + "qede:%s: Failed ddi_intr_get_navail with %s\n", __func__, qede_get_ddi_fail(status)); return (DDI_FAILURE); } @@ -1032,15 +1106,21 @@ qede_alloc_intrs(qede_t * qede) sizeof (qede_vector_info_t); /* Allocate an array big enough for maximum supported */ - intr_ctx->intr_hdl_array = kmem_zalloc(intr_ctx->intr_hdl_array_size, KM_SLEEP); + intr_ctx->intr_hdl_array = kmem_zalloc( + intr_ctx->intr_hdl_array_size, KM_SLEEP); if (intr_ctx->intr_hdl_array == NULL) { - cmn_err(CE_WARN, "qede:%s: Failed to allocate intr_ctx->intr_hdl_array\n", + cmn_err(CE_WARN, + "qede:%s: Failed to allocate" + " intr_ctx->intr_hdl_array\n", __func__); - return(status); + return (status); } - intr_ctx->intr_vect_info = kmem_zalloc(intr_ctx->intr_vect_info_array_size, KM_SLEEP); + intr_ctx->intr_vect_info = kmem_zalloc( + intr_ctx->intr_vect_info_array_size, KM_SLEEP); if (intr_ctx->intr_vect_info_array_size == NULL) { - cmn_err(CE_WARN, "qede:%s: Failed to allocate intr_ctx->vect_info_array_size\n", + cmn_err(CE_WARN, + "qede:%s: Failed to allocate" + " intr_ctx->vect_info_array_size\n", __func__); goto err_exit; } @@ -1053,40 +1133,49 @@ qede_alloc_intrs(qede_t * qede) * (Though we would need to account for the slowpath vector) */ status = ddi_intr_alloc(qede->dip, - intr_ctx->intr_hdl_array, - DDI_INTR_TYPE_MSIX, - 0, - num_to_request, - &actual, - DDI_INTR_ALLOC_STRICT); + intr_ctx->intr_hdl_array, + DDI_INTR_TYPE_MSIX, + 0, + num_to_request, + &actual, + DDI_INTR_ALLOC_STRICT); if (status != DDI_SUCCESS) { - cmn_err(CE_WARN, "qede:%s: Failed to allocate %d interrupts with %s\n", - __func__, num_to_request, qede_get_ddi_fail(status)); - cmn_err(CE_WARN, "qede:%s: Only %d interrupts available.\n", - __func__, actual); + cmn_err(CE_WARN, + "qede:%s: Failed to allocate" + " %d interrupts with %s\n", + __func__, num_to_request, + qede_get_ddi_fail(status)); + cmn_err(CE_WARN, + "qede:%s: Only %d interrupts available.\n", + __func__, actual); goto err_exit; } intr_ctx->intr_vect_allocated = num_to_request; - status = ddi_intr_get_pri(intr_ctx->intr_hdl_array[0], &intr_ctx->intr_pri); + status = ddi_intr_get_pri(intr_ctx->intr_hdl_array[0], + &intr_ctx->intr_pri); if (status != DDI_SUCCESS) { - cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_get_pri with %s\n", - __func__, qede_get_ddi_fail(status)); + cmn_err(CE_WARN, + "qede:%s: Failed ddi_intr_get_pri with %s\n", + __func__, qede_get_ddi_fail(status)); goto err_exit; } - status = ddi_intr_get_cap(intr_ctx->intr_hdl_array[0], &intr_ctx->intr_cap); + status = ddi_intr_get_cap(intr_ctx->intr_hdl_array[0], + &intr_ctx->intr_cap); if (status != DDI_SUCCESS) { - cmn_err(CE_WARN, "qede:%s: Failed ddi_intr_get_cap with %s\n", + cmn_err(CE_WARN, + "qede:%s: Failed ddi_intr_get_cap with %s\n", __func__, qede_get_ddi_fail(status)); goto err_exit; } } else { /* For now we only support type MSIX */ - cmn_err(CE_WARN, "qede:%s: Failed to allocate intr_ctx->intr_hdl_array\n", + cmn_err(CE_WARN, + "qede:%s: Failed to allocate intr_ctx->intr_hdl_array\n", __func__); - return(DDI_FAILURE); + return (DDI_FAILURE); } intr_ctx->intr_mode = ECORE_INT_MODE_MSIX; @@ -1097,25 +1186,54 @@ err_exit: } static void -qede_unconfig_fm(qede_t * qede) +/* LINTED E_FUNC_ARG_UNUSED */ +qede_unconfig_fm(qede_t *qede) { - return; } +/* LINTED E_FUNC_ARG_UNUSED */ static int -qede_config_fm(qede_t * qede) +qede_fm_err_cb(dev_info_t *dip, ddi_fm_error_t *err, + const void *impl_data) { - /*qede_info(qede, "Entered");*/ - return (DDI_SUCCESS); + pci_ereport_post(dip, err, NULL); + return (err->fme_status); } static int -qede_alloc_mem_sb(qede_t *qede, qede_fastpath_t *fp) +qede_config_fm(qede_t * qede) { - return (0); -} + ddi_iblock_cookie_t iblk; + + cmn_err(CE_NOTE, "Entered qede_config_fm\n"); + qede_regs_acc_attr.devacc_attr_access = DDI_FLAGERR_ACC; + qede_desc_acc_attr.devacc_attr_access = DDI_FLAGERR_ACC; + qede_buf_acc_attr.devacc_attr_access = DDI_FLAGERR_ACC; + qede_desc_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR; + qede_gen_buf_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR; + qede_tx_buf_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR; + qede_dma_attr_desc.dma_attr_flags = DDI_DMA_FLAGERR; + qede_dma_attr_txbuf.dma_attr_flags = DDI_DMA_FLAGERR; + qede_dma_attr_rxbuf.dma_attr_flags = DDI_DMA_FLAGERR; + qede_dma_attr_cmddesc.dma_attr_flags = DDI_DMA_FLAGERR; + qede_gen_dma_attr_desc.dma_attr_flags = DDI_DMA_FLAGERR; + qede_buf2k_dma_attr_txbuf.dma_attr_flags = DDI_DMA_FLAGERR; + + ddi_fm_init(qede->dip, &qede->fm_cap, &iblk); + if (DDI_FM_EREPORT_CAP(qede->fm_cap) || + DDI_FM_ERRCB_CAP(qede->fm_cap)) { + pci_ereport_setup(qede->dip); + } + + if (DDI_FM_ERRCB_CAP(qede->fm_cap)) { + ddi_fm_handler_register(qede->dip, + qede_fm_err_cb, (void *)qede); + } + return (DDI_SUCCESS); + +} int qede_dma_mem_alloc(qede_t *qede, @@ -1129,8 +1247,9 @@ qede_dma_mem_alloc(qede_t *qede, *dma_handle = NULL; - if (size <= 0) + if (size <= 0) { return (DDI_ENOMEM); + } err = ddi_dma_alloc_handle(qede->dip, dma_attr, @@ -1217,7 +1336,7 @@ qede_vport_stop(qede_t *qede) { struct ecore_dev *edev = &qede->edev; struct ecore_hwfn *p_hwfn; - int i, status; + int i, status = ECORE_BUSY; for (i = 0; i < edev->num_hwfns; i++) { p_hwfn = &edev->hwfns[i]; @@ -1229,8 +1348,8 @@ qede_vport_stop(qede_t *qede) } status = ecore_sp_vport_stop(p_hwfn, - p_hwfn->hw_info.opaque_fid, - i); /* vport needs fix */ + p_hwfn->hw_info.opaque_fid, + i); /* vport needs fix */ if (status != ECORE_SUCCESS) { cmn_err(CE_WARN, "!qede_vport_stop: " "FAILED for hwfn%d ", i); @@ -1243,7 +1362,7 @@ qede_vport_stop(qede_t *qede) QEDE_VPORT_STOPPED; } - return (DDI_SUCCESS); + return (status); } static uint8_t @@ -1252,9 +1371,12 @@ qede_get_active_rss_params(qede_t *qede, u8 hwfn_id) struct ecore_rss_params rss_params; qede_fastpath_t *fp; int i; - const uint64_t hash_key[] = { 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL, - 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL, - 0x255b0ec26d5a56daULL }; + const uint64_t hash_key[] = + { + 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL, + 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL, + 0x255b0ec26d5a56daULL + }; uint8_t enable_rss = 0; bzero(&rss_params, sizeof (rss_params)); @@ -1282,9 +1404,10 @@ qede_get_active_rss_params(qede_t *qede, u8 hwfn_id) rss_params.rss_table_size_log = 7; /* 2^7 = 128 */ - bcopy(&hash_key[0], &rss_params.rss_key[0], sizeof (rss_params.rss_key)); + bcopy(&hash_key[0], &rss_params.rss_key[0], + sizeof (rss_params.rss_key)); - for (i = 0; i < ECORE_RSS_IND_TABLE_SIZE; i++ ) { + for (i = 0; i < ECORE_RSS_IND_TABLE_SIZE; i++) { fp = &qede->fp_array[i % qede->num_fp]; rss_params.rss_ind_table[i] = (void *)(fp->rx_ring->p_cid); } @@ -1301,8 +1424,9 @@ qede_vport_update(qede_t *qede, struct ecore_hwfn *p_hwfn; struct ecore_sp_vport_update_params *vport_params; struct ecore_sge_tpa_params tpa_params; - int i, status = DDI_SUCCESS; + int status = DDI_SUCCESS; bool new_state; + uint8_t i; cmn_err(CE_NOTE, "qede_vport_update: " "Enter, state = %s%s%s%s%s", @@ -1318,11 +1442,11 @@ qede_vport_update(qede_t *qede, * together. Later we can split them * and set other params as well. */ - if (state == QEDE_VPORT_ON) + if (state == QEDE_VPORT_ON) { new_state = B_TRUE; - else if (state == QEDE_VPORT_OFF) + } else if (state == QEDE_VPORT_OFF) { new_state = B_FALSE; - else { + } else { cmn_err(CE_WARN, "qede_vport_update: " "invalid, state = %d", state); return (DDI_EINVAL); @@ -1339,12 +1463,18 @@ qede_vport_update(qede_t *qede, vport_params->update_vport_active_rx_flg = 1; - vport_params->vport_active_rx_flg = - new_state; + if (new_state == B_TRUE) + vport_params->vport_active_rx_flg = 1; + else + vport_params->vport_active_rx_flg = 0; + vport_params->update_vport_active_tx_flg = 1; - vport_params->vport_active_tx_flg = - new_state; + if (new_state == B_TRUE) + vport_params->vport_active_tx_flg = 1; + else + vport_params->vport_active_tx_flg = 0; + vport_params->update_inner_vlan_removal_flg = 0; vport_params->inner_vlan_removal_flg = @@ -1373,26 +1503,27 @@ qede_vport_update(qede_t *qede, vport_params->accept_flags.update_rx_mode_config = 1; vport_params->accept_flags.update_tx_mode_config = 1; vport_params->accept_flags.rx_accept_filter = - ECORE_ACCEPT_BCAST | - ECORE_ACCEPT_UCAST_UNMATCHED | - ECORE_ACCEPT_MCAST_UNMATCHED; + ECORE_ACCEPT_BCAST | + ECORE_ACCEPT_UCAST_UNMATCHED | + ECORE_ACCEPT_MCAST_UNMATCHED; vport_params->accept_flags.tx_accept_filter = - ECORE_ACCEPT_BCAST | - ECORE_ACCEPT_UCAST_UNMATCHED | - ECORE_ACCEPT_MCAST_UNMATCHED; + ECORE_ACCEPT_BCAST | + ECORE_ACCEPT_UCAST_UNMATCHED | + ECORE_ACCEPT_MCAST_UNMATCHED; vport_params->sge_tpa_params = NULL; if (qede->lro_enable && - new_state == B_TRUE) { + (new_state == B_TRUE)) { qede_print("!%s(%d): enabling LRO ", - __func__, qede->instance); + __func__, qede->instance); - memset(&tpa_params, 0, sizeof (struct ecore_sge_tpa_params)); + memset(&tpa_params, 0, + sizeof (struct ecore_sge_tpa_params)); tpa_params.max_buffers_per_cqe = 5; tpa_params.update_tpa_en_flg = 1; - tpa_params.tpa_ipv4_en_flg = new_state; - tpa_params.tpa_ipv6_en_flg = new_state; + tpa_params.tpa_ipv4_en_flg = 1; + tpa_params.tpa_ipv6_en_flg = 1; tpa_params.tpa_ipv4_tunn_en_flg = 0; tpa_params.tpa_ipv6_tunn_en_flg = 0; tpa_params.update_tpa_param_flg = 1; @@ -1415,7 +1546,6 @@ qede_vport_update(qede_t *qede, vport_params->rss_params = NULL; } -// qede_print_vport_params(qede, vport_params); status = ecore_sp_vport_update(p_hwfn, vport_params, ECORE_SPQ_MODE_EBLOCK, @@ -1425,12 +1555,10 @@ qede_vport_update(qede_t *qede, cmn_err(CE_WARN, "ecore_sp_vport_update: " "FAILED for hwfn%d " " with ", i); -// qede_get_ecore_fail(status)); return (DDI_FAILURE); } cmn_err(CE_NOTE, "!ecore_sp_vport_update: " "SUCCESS for hwfn%d ", i); - //qede->vport_state[i] = state; } @@ -1444,15 +1572,17 @@ qede_vport_start(qede_t *qede) struct ecore_dev *edev = &qede->edev; struct ecore_hwfn *p_hwfn; struct ecore_sp_vport_start_params params; - int i, status; + uint8_t i; + int status = ECORE_BUSY; for (i = 0; i < edev->num_hwfns; i++) { p_hwfn = &edev->hwfns[i]; if ((qede->vport_state[i] != QEDE_VPORT_UNKNOWN) && (qede->vport_state[i] != - QEDE_VPORT_STOPPED)) + QEDE_VPORT_STOPPED)) { continue; + } params.tpa_mode = ECORE_TPA_MODE_NONE; params.remove_inner_vlan = 0; @@ -1462,7 +1592,6 @@ qede_vport_start(qede_t *qede) params.drop_ttl0 = 1; params.max_buffers_per_cqe = 16; params.concrete_fid = p_hwfn->hw_info.concrete_fid; - //params.tpa_buf_size = qede->rx_buf_size; params.opaque_fid = p_hwfn->hw_info.opaque_fid; params.vport_id = i; params.mtu = qede->mtu; @@ -1487,8 +1616,9 @@ qede_update_rx_q_producer(qede_rx_ring_t *rx_ring) { u16 bd_prod = ecore_chain_get_prod_idx(&rx_ring->rx_bd_ring); u16 cqe_prod = ecore_chain_get_prod_idx(&rx_ring->rx_cqe_ring); - u16 sge_prod = 0; - struct eth_rx_prod_data rx_prod_cmd = {0}; + /* LINTED E_FUNC_SET_NOT_USED */ + struct eth_rx_prod_data rx_prod_cmd = { 0 }; + rx_prod_cmd.bd_prod = HOST_TO_LE_32(bd_prod); rx_prod_cmd.cqe_prod = HOST_TO_LE_32(cqe_prod); @@ -1498,7 +1628,7 @@ qede_update_rx_q_producer(qede_rx_ring_t *rx_ring) static int qede_fastpath_stop_queues(qede_t *qede) { - int i,j; + int i, j; int status = DDI_FAILURE; struct ecore_dev *edev; struct ecore_hwfn *p_hwfn; @@ -1507,11 +1637,9 @@ qede_fastpath_stop_queues(qede_t *qede) qede_fastpath_t *fp; qede_rx_ring_t *rx_ring; qede_tx_ring_t *tx_ring; - qede_vector_info_t *vect_info; - int num_fp; ASSERT(qede != NULL); - /*ASSERT(qede->edev != NULL);*/ + /* ASSERT(qede->edev != NULL); */ edev = &qede->edev; @@ -1530,17 +1658,18 @@ qede_fastpath_stop_queues(qede_t *qede) tx_ring = fp->tx_ring[j]; if (tx_ring->queue_started == B_TRUE) { cmn_err(CE_WARN, "Stopping tx queue " - "%d:%d. ", i, j); + "%d:%d. ", i, j); p_tx_cid = tx_ring->p_cid; status = ecore_eth_tx_queue_stop(p_hwfn, - (void *)p_tx_cid); + (void *)p_tx_cid); if (status != ECORE_SUCCESS) { cmn_err(CE_WARN, "FAILED to " - "stop tx queue %d:%d", i, j); + "stop tx queue %d:%d", i, j); return (DDI_FAILURE); } tx_ring->queue_started = B_FALSE; - cmn_err(CE_NOTE, "tx_ring %d:%d stopped\n", i, j); + cmn_err(CE_NOTE, "tx_ring %d:%d stopped\n", i, + j); } } @@ -1552,9 +1681,9 @@ qede_fastpath_stop_queues(qede_t *qede) (void *)p_rx_cid, B_TRUE, B_FALSE); if (status != ECORE_SUCCESS) { cmn_err(CE_WARN, "FAILED to " - "stop rx queue %d " - "with ecore status %s", - i, qede_get_ecore_fail(status)); + "stop rx queue %d " + "with ecore status %s", + i, qede_get_ecore_fail(status)); return (DDI_FAILURE); } rx_ring->queue_started = B_FALSE; @@ -1577,7 +1706,7 @@ qede_fastpath_stop_queues(qede_t *qede) static int qede_fastpath_start_queues(qede_t *qede) { - int i,j; + int i, j; int status = DDI_FAILURE; struct ecore_dev *edev; struct ecore_hwfn *p_hwfn; @@ -1587,13 +1716,11 @@ qede_fastpath_start_queues(qede_t *qede) qede_fastpath_t *fp; qede_rx_ring_t *rx_ring; qede_tx_ring_t *tx_ring; - qede_vector_info_t *vect_info; dma_addr_t p_phys_table; u16 page_cnt; - int num_fp; ASSERT(qede != NULL); - /*ASSERT(qede->edev != NULL);*/ + /* ASSERT(qede->edev != NULL); */ edev = &qede->edev; status = qede_vport_start(qede); @@ -1629,7 +1756,7 @@ qede_fastpath_start_queues(qede_t *qede) rx_ring->p_cid = rx_ret_params.p_handle; if (status != DDI_SUCCESS) { cmn_err(CE_WARN, "ecore_sp_eth_rx_queue_start " - "FAILED for rxq%d", i); + "FAILED for rxq%d", i); return (DDI_FAILURE); } rx_ring->hw_cons_ptr = &fp->sb_info->sb_virt->pi_array[RX_PI]; @@ -1650,8 +1777,10 @@ qede_fastpath_start_queues(qede_t *qede) params.p_sb = fp->sb_info; params.sb_idx = TX_PI(j); - p_phys_table = ecore_chain_get_pbl_phys(&tx_ring->tx_bd_ring); - page_cnt = ecore_chain_get_page_cnt(&tx_ring->tx_bd_ring); + p_phys_table = ecore_chain_get_pbl_phys( + &tx_ring->tx_bd_ring); + page_cnt = ecore_chain_get_page_cnt( + &tx_ring->tx_bd_ring); status = ecore_eth_tx_queue_start(p_hwfn, p_hwfn->hw_info.opaque_fid, ¶ms, @@ -1663,14 +1792,18 @@ qede_fastpath_start_queues(qede_t *qede) tx_ring->p_cid = tx_ret_params.p_handle; if (status != DDI_SUCCESS) { cmn_err(CE_WARN, "ecore_sp_eth_tx_queue_start " - "FAILED for txq%d:%d", i,j); + "FAILED for txq%d:%d", i,j); return (DDI_FAILURE); } - tx_ring->hw_cons_ptr = &fp->sb_info->sb_virt->pi_array[TX_PI(j)]; + tx_ring->hw_cons_ptr = + &fp->sb_info->sb_virt->pi_array[TX_PI(j)]; + /* LINTED E_CONSTANT_CONDITION */ SET_FIELD(tx_ring->tx_db.data.params, ETH_DB_DATA_DEST, DB_DEST_XCM); + /* LINTED E_CONSTANT_CONDITION */ SET_FIELD(tx_ring->tx_db.data.params, ETH_DB_DATA_AGG_CMD, DB_AGG_CMD_SET); + /* LINTED E_CONSTANT_CONDITION */ SET_FIELD(tx_ring->tx_db.data.params, ETH_DB_DATA_AGG_VAL_SEL, DQ_XCM_ETH_TX_BD_PROD_CMD); tx_ring->tx_db.data.agg_flags = DQ_XCM_ETH_DQ_CF_CMD; @@ -1712,11 +1845,13 @@ qede_free_lro_rx_buffers(qede_rx_ring_t *rx_ring) for (i = 0; i < ETH_TPA_MAX_AGGS_NUM; i++) { lro_info = &rx_ring->lro_info[i]; - if (lro_info->agg_state == QEDE_AGG_STATE_NONE) + if (lro_info->agg_state == QEDE_AGG_STATE_NONE) { continue; + } for (j = 0; j < QEDE_MAX_BD_PER_AGG; j++) { - if (lro_info->rx_buffer[j] == NULL) + if (lro_info->rx_buffer[j] == NULL) { break; + } qede_recycle_copied_rx_buffer( lro_info->rx_buffer[j]); lro_info->rx_buffer[j] = NULL; @@ -1730,7 +1865,7 @@ qede_free_rx_buffers_legacy(qede_t *qede, qede_rx_buf_area_t *rx_buf_area) { int i, j; u32 ref_cnt, bufs_per_page; - qede_rx_buffer_t *rx_buffer, *first_rx_buf_in_page; + qede_rx_buffer_t *rx_buffer, *first_rx_buf_in_page = 0; qede_rx_ring_t *rx_ring = rx_buf_area->rx_ring; bool free_rx_buffer; @@ -1741,22 +1876,26 @@ qede_free_rx_buffers_legacy(qede_t *qede, qede_rx_buf_area_t *rx_buf_area) if (rx_buf_area) { for (i = 0; i < rx_ring->rx_buf_count; i += bufs_per_page) { free_rx_buffer = B_TRUE; - first_rx_buf_in_page = NULL; for (j = 0; j < bufs_per_page; j++) { - if (!j) + if (!j) { first_rx_buf_in_page = rx_buffer; + } if (rx_buffer->ref_cnt != 0) { ref_cnt = atomic_dec_32_nv( &rx_buffer->ref_cnt); if (ref_cnt == 0) { - /* Buffer is now completely free */ + /* + * Buffer is now + * completely free + */ if (rx_buffer->mp) { freemsg(rx_buffer->mp); rx_buffer->mp = NULL; } } else { /* - * Since Buffer still held up in Stack, + * Since Buffer still + * held up in Stack, * we cant free the whole page */ free_rx_buffer = B_FALSE; @@ -1765,18 +1904,27 @@ qede_free_rx_buffers_legacy(qede_t *qede, qede_rx_buf_area_t *rx_buf_area) rx_buffer++; } - if (free_rx_buffer == B_TRUE && first_rx_buf_in_page != NULL) { - qede_pci_free_consistent(&first_rx_buf_in_page->dma_info.dma_handle, + if (free_rx_buffer == B_TRUE) { + qede_pci_free_consistent( + &first_rx_buf_in_page->dma_info.dma_handle, &first_rx_buf_in_page->dma_info.acc_handle); } } - /* If no more buffers are with the stack then free the buf pools */ + /* + * If no more buffers are with the stack + * then free the buf pools + */ if (rx_buf_area->buf_upstream == 0) { mutex_destroy(&rx_buf_area->active_buf_list.lock); mutex_destroy(&rx_buf_area->passive_buf_list.lock); kmem_free(rx_buf_area, sizeof (qede_rx_buf_area_t)); + rx_buf_area = NULL; + if (atomic_cas_32(&qede->detach_unsafe, 2, 2)) { + atomic_dec_32(&qede->detach_unsafe); + } + } } } @@ -1794,7 +1942,6 @@ static void qede_free_rx_ring_phys(qede_t *qede, qede_fastpath_t *fp) { qede_rx_ring_t *rx_ring; - size_t size; ASSERT(qede != NULL); ASSERT(fp != NULL); @@ -1814,13 +1961,14 @@ qede_free_rx_ring_phys(qede_t *qede, qede_fastpath_t *fp) if (rx_ring->rx_cqe_ring.p_virt_addr) { ecore_chain_free(&qede->edev, &rx_ring->rx_cqe_ring); rx_ring->rx_cqe_ring.p_virt_addr = NULL; - if(rx_ring->rx_cqe_ring.pbl_sp.p_virt_table) + if (rx_ring->rx_cqe_ring.pbl_sp.p_virt_table) { rx_ring->rx_cqe_ring.pbl_sp.p_virt_table = NULL; + } } rx_ring->hw_cons_ptr = NULL; rx_ring->hw_rxq_prod_addr = NULL; rx_ring->sw_rx_cons = 0; - rx_ring->sw_rx_prod =0; + rx_ring->sw_rx_prod = 0; } @@ -1828,21 +1976,17 @@ qede_free_rx_ring_phys(qede_t *qede, qede_fastpath_t *fp) static int qede_init_bd(qede_t *qede, qede_rx_ring_t *rx_ring) { - u16 prod_idx; struct eth_rx_bd *bd = NULL; int ret = DDI_SUCCESS; int i; qede_rx_buffer_t *rx_buffer; qede_rx_buf_area_t *rx_buf_area = rx_ring->rx_buf_area; qede_rx_buf_list_t *active_buf_list = &rx_buf_area->active_buf_list; - u16 tail = 0; for (i = 0; i < rx_ring->rx_buf_count; i++) { rx_buffer = &rx_buf_area->rx_buf_pool[i]; active_buf_list->buf_list[i] = rx_buffer; active_buf_list->num_entries++; - tail = i; - prod_idx = ecore_chain_get_prod_idx(&rx_ring->rx_bd_ring) & RX_RING_MASK; bd = ecore_chain_produce(&rx_ring->rx_bd_ring); if (bd == NULL) { qede_print_err("!%s(%d): invalid NULL bd in " @@ -1851,12 +1995,10 @@ qede_init_bd(qede_t *qede, qede_rx_ring_t *rx_ring) goto err; } - bd->addr.lo = HOST_TO_LE_32(U64_LO(rx_buffer->dma_info.phys_addr)); - bd->addr.hi = HOST_TO_LE_32(U64_HI(rx_buffer->dma_info.phys_addr)); - - - - + bd->addr.lo = HOST_TO_LE_32(U64_LO( + rx_buffer->dma_info.phys_addr)); + bd->addr.hi = HOST_TO_LE_32(U64_HI( + rx_buffer->dma_info.phys_addr)); } active_buf_list->tail = 0; @@ -1881,7 +2023,7 @@ qede_get_from_active_list(qede_rx_ring_t *rx_ring, if (rx_buffer) { atomic_dec_32(&active_buf_list->num_entries); atomic_inc_32(&rx_ring->rx_buf_area->buf_upstream); - atomic_inc_32(&rx_buffer->ref_cnt); // qede_get_from_active_list() + atomic_inc_32(&rx_buffer->ref_cnt); rx_buffer->buf_state = RX_BUF_STATE_WITH_OS; if (rx_buffer->mp == NULL) { @@ -1943,8 +2085,17 @@ qede_replenish_rx_buffers(qede_rx_ring_t *rx_ring) qede_rx_buffer_t *rx_buffer; int count = 0; struct eth_rx_bd *bd; - qede_rx_buf_list_t *passive_buf_list= - &rx_ring->rx_buf_area->passive_buf_list; + + /* + * Only replenish when we have at least + * 1/4th of the ring to do. We don't want + * to incur many lock contentions and + * cycles for just a few buffers. + * We don't bother with the passive area lock + * here because we're just getting an + * estimate. Also, we only pull from + * the passive list in this function. + */ /* * Use a replenish lock because we can do the @@ -1954,7 +2105,9 @@ qede_replenish_rx_buffers(qede_rx_ring_t *rx_ring) * layers. */ if (mutex_tryenter(&rx_ring->rx_replen_lock) == 0) { - qede_info(rx_ring->qede, "Failed to take replenish_lock"); + qede_info(rx_ring->qede, "!%s(%d): Failed to take" + " replenish_lock", + __func__, rx_ring->qede->instance); return; } @@ -1963,13 +2116,16 @@ qede_replenish_rx_buffers(qede_rx_ring_t *rx_ring) while (rx_buffer != NULL) { bd = ecore_chain_produce(&rx_ring->rx_bd_ring); if (bd == NULL) { - qede_info(rx_ring->qede, "bd = null"); + qede_info(rx_ring->qede, "!%s(%d): bd = null", + __func__, rx_ring->qede->instance); qede_put_to_passive_list(rx_ring, rx_buffer); break; } - bd->addr.lo = HOST_TO_LE_32(U64_LO(rx_buffer->dma_info.phys_addr)); - bd->addr.hi = HOST_TO_LE_32(U64_HI(rx_buffer->dma_info.phys_addr)); + bd->addr.lo = HOST_TO_LE_32(U64_LO( + rx_buffer->dma_info.phys_addr)); + bd->addr.hi = HOST_TO_LE_32( + U64_HI(rx_buffer->dma_info.phys_addr)); /* * Put the buffer in active list since it will be @@ -1989,7 +2145,7 @@ qede_replenish_rx_buffers(qede_rx_ring_t *rx_ring) int qede_put_to_passive_list(qede_rx_ring_t *rx_ring, qede_rx_buffer_t *rx_buffer) { - qede_rx_buf_list_t *passive_buf_list= + qede_rx_buf_list_t *passive_buf_list = &rx_ring->rx_buf_area->passive_buf_list; qede_rx_buf_area_t *rx_buf_area = rx_ring->rx_buf_area; int tail = 0; @@ -2010,12 +2166,13 @@ qede_put_to_passive_list(qede_rx_ring_t *rx_ring, qede_rx_buffer_t *rx_buffer) rx_ring->rx_buf_count); } mutex_exit(&passive_buf_list->lock); - return passive_buf_list->num_entries; + return (passive_buf_list->num_entries); } void qede_recycle_rx_buffer(char *arg) { + /* LINTED E_BAD_PTR_CAST_ALIGN */ qede_rx_buffer_t *rx_buffer = (qede_rx_buffer_t *)arg; qede_rx_ring_t *rx_ring = rx_buffer->rx_ring; qede_rx_buf_area_t *rx_buf_area = rx_buffer->rx_buf_area; @@ -2035,7 +2192,7 @@ qede_recycle_rx_buffer(char *arg) rx_buffer->mp = desballoc(rx_buffer->dma_info.virt_addr, rx_ring->rx_buf_size, 0, &rx_buffer->recycle); - ref_cnt = atomic_dec_32_nv(&rx_buffer->ref_cnt); // qede_recycle_rx_buffer() + ref_cnt = atomic_dec_32_nv(&rx_buffer->ref_cnt); if (ref_cnt == 1) { /* Put the buffer into passive_buf_list to be reused */ num_entries = qede_put_to_passive_list(rx_ring, rx_buffer); @@ -2047,7 +2204,8 @@ qede_recycle_rx_buffer(char *arg) } } } else if (ref_cnt == 0) { - /* This is a buffer from a previous load instance of + /* + * This is a buffer from a previous load instance of * rx_buf_area. Free the rx_buffer and if no more * buffers are upstream from this rx_buf_area instance * then free the rx_buf_area; @@ -2062,7 +2220,7 @@ qede_recycle_rx_buffer(char *arg) if (buf_upstream >= 1) { atomic_dec_32(&rx_buf_area->buf_upstream); } - if (rx_buf_area->inactive && rx_buf_area->buf_upstream == 0) { + if (rx_buf_area->inactive && (rx_buf_area->buf_upstream == 0)) { qede_free_rx_buffers_legacy(qede, rx_buf_area); } @@ -2088,7 +2246,8 @@ qede_recycle_copied_rx_buffer(qede_rx_buffer_t *rx_buffer) * Can happen if the buffer is being free'd * in the stop routine */ - qede_info(qede, "rx_buffer->ref_cnt = 0"); + qede_info(qede, "!%s(%d): rx_buffer->ref_cnt = 0", + __func__, qede->instance); return; } @@ -2104,16 +2263,14 @@ qede_recycle_copied_rx_buffer(qede_rx_buffer_t *rx_buffer) * Though we could also be recycling a buffer that got copied, * so in that case the mp would still be intact. */ - //if(rx_buffer->mp == NULL) -// rx_buffer->mp = desballoc(rx_buffer->dma_info.virt_addr, -// rx_ring->rx_buf_size, 0, &rx_buffer->recycle); - ref_cnt = atomic_dec_32_nv(&rx_buffer->ref_cnt); // qede_recycle_rx_buffer() + ref_cnt = atomic_dec_32_nv(&rx_buffer->ref_cnt); if (ref_cnt == 1) { qede_put_to_passive_list(rx_ring, rx_buffer); /* Put the buffer into passive_buf_list to be reused */ } else if (ref_cnt == 0) { - /* This is a buffer from a previous load instance of + /* + * This is a buffer from a previous load instance of * rx_buf_area. Free the rx_buffer and if no more * buffers are upstream from this rx_buf_area instance * then free the rx_buf_area; @@ -2126,7 +2283,7 @@ qede_recycle_copied_rx_buffer(qede_rx_buffer_t *rx_buffer) rx_buffer->mp = NULL; } - if (rx_buf_area->inactive && rx_buf_area->buf_upstream == 0) { + if (rx_buf_area->inactive && (rx_buf_area->buf_upstream == 0)) { mutex_enter(&qede->drv_lock); qede_free_rx_buffers_legacy(qede, rx_buf_area); mutex_exit(&qede->drv_lock); @@ -2144,18 +2301,15 @@ static int qede_alloc_rx_buffers(qede_t *qede, qede_rx_ring_t *rx_ring) { int ret = DDI_SUCCESS, i, j; - qede_rx_buffer_t *rx_buf_pool; qede_rx_buffer_t *rx_buffer; qede_rx_buf_area_t *rx_buf_area = rx_ring->rx_buf_area; - struct eth_rx_bd *bd = NULL; - uint16_t prod_idx; u32 bufs_per_page, buf_size; - int page_size = (int) ddi_ptob(qede->dip, 1); + int page_size = (int)ddi_ptob(qede->dip, 1); qede_dma_info_t *dma_info; ddi_dma_cookie_t temp_cookie; int allocated = 0; u64 dma_addr; - u8 *vaddr; + u8 *vaddr; ddi_dma_handle_t dma_handle; ddi_acc_handle_t acc_handle; @@ -2180,14 +2334,14 @@ qede_alloc_rx_buffers(qede_t *qede, qede_rx_ring_t *rx_ring) dma_info = &rx_buffer->dma_info; ret = qede_dma_mem_alloc(qede, - buf_size, - DDI_DMA_READ | DDI_DMA_STREAMING | DDI_DMA_CONSISTENT, - (caddr_t *)&dma_info->virt_addr, - &temp_cookie, - &dma_info->dma_handle, - &dma_info->acc_handle, - &qede_dma_attr_rxbuf, - &qede_buf_acc_attr); + buf_size, + DDI_DMA_READ | DDI_DMA_STREAMING | DDI_DMA_CONSISTENT, + (caddr_t *)&dma_info->virt_addr, + &temp_cookie, + &dma_info->dma_handle, + &dma_info->acc_handle, + &qede_dma_attr_rxbuf, + &qede_buf_acc_attr); if (ret != DDI_SUCCESS) { goto err; } @@ -2210,22 +2364,22 @@ qede_alloc_rx_buffers(qede_t *qede, qede_rx_ring_t *rx_ring) rx_buffer->recycle.free_arg = (caddr_t)rx_buffer; rx_buffer->mp = desballoc(dma_info->virt_addr, - rx_ring->rx_buf_size, 0, - &rx_buffer->recycle); + rx_ring->rx_buf_size, 0, + &rx_buffer->recycle); if (rx_buffer->mp == NULL) { - qede_warn(qede, "desballoc() failed, index %d", i); + qede_warn(qede, "desballoc() failed, index %d", + i); } rx_buffer->rx_ring = rx_ring; rx_buffer->rx_buf_area = rx_buf_area; rx_buffer->index = i + j; - rx_buffer->ref_cnt = 1; // qede_alloc_rx_buffers() + rx_buffer->ref_cnt = 1; rx_buffer++; vaddr += rx_ring->rx_buf_size; dma_addr += rx_ring->rx_buf_size; } rx_ring->sw_rx_prod++; -// allocated++; } /* @@ -2257,13 +2411,14 @@ qede_alloc_rx_ring_phys(qede_t *qede, qede_fastpath_t *fp) rx_ring = fp->rx_ring; - size = sizeof (qede_rx_buffer_t) * qede->rx_ring_size; + atomic_inc_32(&qede->detach_unsafe); /* * Allocate rx_buf_area for the plumb instance */ rx_buf_area = kmem_zalloc(sizeof (*rx_buf_area), KM_SLEEP); if (rx_buf_area == NULL) { - qede_info(qede, "Cannot alloc rx_buf_area"); + qede_info(qede, "!%s(%d): Cannot alloc rx_buf_area", + __func__, qede->instance); return (DDI_FAILURE); } @@ -2290,7 +2445,7 @@ qede_alloc_rx_ring_phys(qede_t *qede, qede_fastpath_t *fp) ECORE_CHAIN_MODE_PBL, ECORE_CHAIN_CNT_TYPE_U16, qede->rx_ring_size, - sizeof(union eth_rx_cqe), + sizeof (union eth_rx_cqe), &rx_ring->rx_cqe_ring, NULL) != ECORE_SUCCESS) { cmn_err(CE_WARN, "Failed to allocate " @@ -2322,7 +2477,6 @@ qede_free_tx_bd_ring(qede_t *qede, qede_fastpath_t *fp) if (tx_ring->tx_bd_ring.p_virt_addr) { ecore_chain_free(&qede->edev, &tx_ring->tx_bd_ring); tx_ring->tx_bd_ring.p_virt_addr = NULL; - /*cmn_err(CE_NOTE, "!%s(%d): tx bd ring freed\n", __func__, qede->instance);*/ } tx_ring->hw_cons_ptr = NULL; tx_ring->sw_tx_cons = 0; @@ -2356,7 +2510,7 @@ error: } static void -qede_free_tx_bcopy_buffers(qede_t *qede, qede_tx_ring_t *tx_ring) +qede_free_tx_bcopy_buffers(qede_tx_ring_t *tx_ring) { qede_tx_bcopy_pkt_t *bcopy_pkt; int i; @@ -2415,7 +2569,8 @@ qede_alloc_tx_bcopy_buffers(qede_t *qede, qede_tx_ring_t *tx_ring) size = sizeof (qede_tx_bcopy_pkt_t) * qede->tx_ring_size; bcopy_list = kmem_zalloc(size, KM_SLEEP); if (bcopy_list == NULL) { - qede_warn(qede, "Failed to allocate bcopy_list"); + qede_warn(qede, "!%s(%d): Failed to allocate bcopy_list", + __func__, qede->instance); ret = DDI_FAILURE; goto exit; } @@ -2497,7 +2652,9 @@ qede_alloc_tx_dma_handles(qede_t *qede, qede_tx_ring_t *tx_ring) size = sizeof (qede_dma_handle_entry_t) * qede->tx_ring_size; dmah_list = kmem_zalloc(size, KM_SLEEP); if (dmah_list == NULL) { - qede_warn(qede, "Failed to allocated dmah_list"); + qede_warn(qede, "!%s(%d): Failed to allocated dmah_list", + __func__, qede->instance); + /* LINTED E_CONST_TRUNCATED_BY_ASSIGN */ ret = DDI_FAILURE; goto exit; } @@ -2523,6 +2680,7 @@ qede_alloc_tx_dma_handles(qede_t *qede, qede_tx_ring_t *tx_ring) qede_print_err("!%s(%d): dma alloc handle failed " "for index %d", __func__, qede->instance, i); + /* LINTED E_CONST_TRUNCATED_BY_ASSIGN */ ret = DDI_FAILURE; goto exit; } @@ -2537,7 +2695,7 @@ exit: static u32 qede_alloc_tx_ring_phys(qede_t *qede, qede_fastpath_t *fp) { - int i, tc; + int i; qede_tx_ring_t *tx_ring; u32 ret = DDI_SUCCESS; size_t size; @@ -2556,7 +2714,7 @@ qede_alloc_tx_ring_phys(qede_t *qede, qede_fastpath_t *fp) ret = qede_alloc_tx_bd_ring(qede, tx_ring); if (ret) { cmn_err(CE_WARN, "!%s(%d): failed, %s", - __func__, qede->instance,qede_get_ddi_fail(ret)); + __func__, qede->instance, qede_get_ddi_fail(ret)); return (ret); } @@ -2567,6 +2725,7 @@ qede_alloc_tx_ring_phys(qede_t *qede, qede_fastpath_t *fp) if (ret) { qede_print_err("!%s(%d): Failed to alloc tx copy " "buffers", __func__, qede->instance); + /* LINTED E_CONST_TRUNCATED_BY_ASSIGN */ ret = DDI_FAILURE; goto exit; } @@ -2578,6 +2737,7 @@ qede_alloc_tx_ring_phys(qede_t *qede, qede_fastpath_t *fp) if (ret) { qede_print_err("!%s(%d): Failed to alloc tx dma " "handles", __func__, qede->instance); + /* LINTED E_CONST_TRUNCATED_BY_ASSIGN */ ret = DDI_FAILURE; goto exit; } @@ -2586,7 +2746,9 @@ qede_alloc_tx_ring_phys(qede_t *qede, qede_fastpath_t *fp) size = sizeof (qede_tx_recycle_list_t) * qede->tx_ring_size; recycle_list = kmem_zalloc(size, KM_SLEEP); if (recycle_list == NULL) { - qede_warn(qede, "Failed to allocate tx_recycle_list"); + qede_warn(qede, "!%s(%d): Failed to allocate" + " tx_recycle_list", __func__, qede->instance); + /* LINTED E_CONST_TRUNCATED_BY_ASSIGN */ ret = DDI_FAILURE; goto exit; } @@ -2598,6 +2760,7 @@ exit: } static void +/* LINTED E_FUNC_ARG_UNUSED */ qede_free_sb_phys(qede_t *qede, qede_fastpath_t *fp) { qede_pci_free_consistent(&fp->sb_dma_handle, &fp->sb_acc_handle); @@ -2610,8 +2773,6 @@ qede_alloc_sb_phys(qede_t *qede, qede_fastpath_t *fp) { int status; int sb_id; - struct status_block *sb_addr; - uint64_t sb_phyaddr; struct ecore_dev *edev = &qede->edev; struct ecore_hwfn *p_hwfn; qede_vector_info_t *vect_info = fp->vect_info; @@ -2651,11 +2812,11 @@ qede_alloc_sb_phys(qede_t *qede, qede_fastpath_t *fp) status = ecore_int_sb_init(p_hwfn, - p_hwfn->p_main_ptt, - fp->sb_info, - (void *)fp->sb_virt, - fp->sb_phys, - fp->fp_index); + p_hwfn->p_main_ptt, + fp->sb_info, + (void *)fp->sb_virt, + fp->sb_phys, + fp->fp_index); if (status != ECORE_SUCCESS) { cmn_err(CE_WARN, "Failed ecore_int_sb_init"); return (DDI_FAILURE); @@ -2673,12 +2834,12 @@ qede_free_tx_ring_phys(qede_t *qede, qede_fastpath_t *fp) for (i = 0; i < qede->num_tc; i++) { tx_ring = fp->tx_ring[i]; qede_free_tx_dma_handles(qede, tx_ring); - qede_free_tx_bcopy_buffers(qede, tx_ring); + qede_free_tx_bcopy_buffers(tx_ring); qede_free_tx_bd_ring(qede, fp); if (tx_ring->tx_recycle_list) { kmem_free(tx_ring->tx_recycle_list, - sizeof(qede_tx_recycle_list_t) + sizeof (qede_tx_recycle_list_t) * qede->tx_ring_size); } } @@ -2687,7 +2848,7 @@ qede_free_tx_ring_phys(qede_t *qede, qede_fastpath_t *fp) static void qede_fastpath_free_phys_mem(qede_t *qede) { - int status = 0, i; + int i; qede_fastpath_t *fp; for (i = 0; i < qede->num_fp; i++) { @@ -2709,7 +2870,6 @@ qede_save_fp_dma_handles(qede_t *qede, qede_fastpath_t *fp) int ret, i; qede_rx_ring_t *rx_ring; qede_tx_ring_t *tx_ring; - dma_addr_t p_phys_table; rx_ring = fp->rx_ring; @@ -2734,15 +2894,14 @@ qede_save_fp_dma_handles(qede_t *qede, qede_fastpath_t *fp) rx_ring->rx_cqe_ring.p_phys_addr); goto exit; } - p_phys_table = ecore_chain_get_pbl_phys(&rx_ring->rx_cqe_ring); /* rx cqe ring pbl */ ret = qede_osal_find_dma_handle_for_block(qede, - (void *)p_phys_table, + (void *)rx_ring->rx_cqe_ring.pbl_sp.p_phys_table, &rx_ring->rx_cqe_pbl_dmah); if (ret) { qede_print_err("!%s(%d): Cannot find dma_handle for " "rx_cqe pbl, addr %p", __func__, qede->instance, - p_phys_table); + rx_ring->rx_cqe_ring.pbl_sp.p_phys_table); goto exit; } @@ -2761,14 +2920,13 @@ qede_save_fp_dma_handles(qede_t *qede, qede_fastpath_t *fp) goto exit; } - p_phys_table = ecore_chain_get_pbl_phys(&tx_ring->tx_bd_ring); ret = qede_osal_find_dma_handle_for_block(qede, - (void *)p_phys_table, + (void *)tx_ring->tx_bd_ring.pbl_sp.p_phys_table, &tx_ring->tx_pbl_dmah); if (ret) { qede_print_err("!%s(%d): Cannot find dma_handle for " "tx_bd pbl, addr %p", __func__, qede->instance, - p_phys_table); + tx_ring->tx_bd_ring.pbl_sp.p_phys_table); goto exit; } } @@ -2787,21 +2945,25 @@ qede_fastpath_alloc_phys_mem(qede_t *qede) fp = &qede->fp_array[i]; status = qede_alloc_sb_phys(qede, fp); - if (status != DDI_SUCCESS) + if (status != DDI_SUCCESS) { goto err; + } status = qede_alloc_rx_ring_phys(qede, fp); - if (status != DDI_SUCCESS) + if (status != DDI_SUCCESS) { goto err; + } status = qede_alloc_tx_ring_phys(qede, fp); - if (status != DDI_SUCCESS) + if (status != DDI_SUCCESS) { goto err; + } status = qede_save_fp_dma_handles(qede, fp); - if (status != DDI_SUCCESS) + if (status != DDI_SUCCESS) { goto err; + } } - return(status); + return (status); err: qede_fastpath_free_phys_mem(qede); return (status); @@ -2815,7 +2977,6 @@ qede_fastpath_config(qede_t *qede) qede_rx_ring_t *rx_ring; qede_tx_ring_t *tx_ring; qede_vector_info_t *vect_info; - struct tx_recycle_entry *recycle_entries; int num_fp, num_hwfns; ASSERT(qede != NULL); @@ -2857,7 +3018,6 @@ qede_fastpath_config(qede_t *qede) rx_ring->rx_buf_size = qede->rx_buf_size; rx_ring->qede = qede; rx_ring->sw_rx_cons = 0; -// rx_ring->sw_rx_prod = 0; rx_ring->rx_copy_threshold = qede->rx_copy_threshold; rx_ring->rx_low_buffer_threshold = qede->rx_low_buffer_threshold; @@ -2870,7 +3030,8 @@ qede_fastpath_config(qede_t *qede) tx_ring->qede = qede; tx_ring->fp = fp; tx_ring->fp_idx = i; - tx_ring->tx_queue_index = i * qede->num_fp + fp->fp_index; + tx_ring->tx_queue_index = i * qede->num_fp + + fp->fp_index; tx_ring->tx_buf_size = qede->tx_buf_size; tx_ring->tx_ring_size = qede->tx_ring_size; tx_ring->queue_started = B_FALSE; @@ -2915,7 +3076,7 @@ qede_configure_link(qede_t *qede, bool op) ecore_ptt_release(hwfn, ptt); if (ret) { - /* if link config fails, make sure ptt is released */ + /* if link config fails, make sure ptt is released */ goto exit; } } @@ -2929,9 +3090,7 @@ exit: int qede_stop(qede_t *qede) { - int status, i, count; - qede_fastpath_t *fp; - qede_rx_ring_t *rx_ring; + int status; ASSERT(mutex_owned(&qede->drv_lock)); qede->qede_state = QEDE_STATE_STOPPING; @@ -2941,6 +3100,7 @@ qede_stop(qede_t *qede) qede_disable_all_fastpath_intrs(qede); status = qede_configure_link(qede, 0 /* Re-Set */); if (status) { + /* LINTED E_BAD_FORMAT_ARG_TYPE2 */ cmn_err(CE_NOTE, "!%s(%d): Failed to reset link", __func__, qede->instance); return (status); @@ -2948,6 +3108,7 @@ qede_stop(qede_t *qede) qede_clear_filters(qede); status = qede_fastpath_stop_queues(qede); if (status != DDI_SUCCESS) { + /* LINTED E_BAD_FORMAT_ARG_TYPE2 */ cmn_err(CE_WARN, "qede_stop:" " qede_fastpath_stop_queues FAILED " " qede=%p\n", @@ -2958,6 +3119,7 @@ qede_stop(qede_t *qede) qede_fastpath_free_phys_mem(qede); qede->qede_state = QEDE_STATE_STOPPED; + /* LINTED E_BAD_FORMAT_ARG_TYPE2 */ cmn_err(CE_WARN, "qede_stop SUCCESS =%p\n", qede); return (DDI_SUCCESS); } @@ -2981,12 +3143,12 @@ qede_start(qede_t *qede) * the sb_info, rx_ring and tx_rings */ if (qede_fastpath_config(qede) != DDI_SUCCESS) { + /* LINTED E_BAD_FORMAT_ARG_TYPE2 */ qede_print_err("!%s(%d): qede_fastpath_config failed", __func__, qede->instance); return (DDI_FAILURE); } - /*cmn_err(CE_NOTE, "qede_start fastpath_config qede=%p\n", qede);*/ /* * Allocate the physical memory @@ -2998,7 +3160,6 @@ qede_start(qede_t *qede) " failed qede=%p\n", qede); return (DDI_FAILURE); } - /*cmn_err(CE_NOTE, "qede_start fastpath_alloc_phys_mem qede=%p\n", qede);*/ status = qede_fastpath_start_queues(qede); if (status) { @@ -3019,13 +3180,16 @@ qede_start(qede_t *qede) /* * Put interface in regular mode */ - if (qede_set_filter_rx_mode(qede, QEDE_FILTER_RX_MODE_REGULAR) != DDI_SUCCESS) { - qede_warn(qede, "Failed to set filter mode"); + if (qede_set_filter_rx_mode(qede, + QEDE_FILTER_RX_MODE_REGULAR) != DDI_SUCCESS) { + cmn_err(CE_NOTE, "!%s(%d): Failed to set filter mode", + __func__, qede->instance); goto err_out1; } status = qede_enable_all_fastpath_intrs(qede); if (status) { + /* LINTED E_BAD_FORMAT_ARG_TYPE2 */ cmn_err(CE_NOTE, "!%s(%d): Failed to enable intrs", __func__, qede->instance); goto err_out2; @@ -3037,7 +3201,7 @@ qede_start(qede_t *qede) return (status); err_out2: - (void)qede_fastpath_stop_queues(qede); + (void) qede_fastpath_stop_queues(qede); err_out1: qede_fastpath_free_phys_mem(qede); return (DDI_FAILURE); @@ -3156,16 +3320,14 @@ qede_suspend(qede_t *qede) } static int -qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) +qede_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) { - qede_t * qede; + qede_t *qede; struct ecore_dev *edev; int instance; uint32_t vendor_id; uint32_t device_id; struct ecore_hwfn *p_hwfn; - struct ecore_sb_sp_info *sp_sb; - struct ecore_sb_attn_info *attn_sb; struct ecore_ptt *p_ptt; struct ecore_mcp_link_params *link_params; struct ecore_hw_init_params hw_init_params; @@ -3174,16 +3336,14 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) uint32_t num_props; int rc = 0; - switch (cmd) - { + switch (cmd) { default: return (DDI_FAILURE); case DDI_RESUME: { qede = (qede_t * )ddi_get_driver_private(dip); - if (qede == NULL || qede->dip != dip) - { + if (qede == NULL || qede->dip != dip) { cmn_err(CE_NOTE, "qede:%s: Could not allocate" " adapter structure\n", __func__); return (DDI_FAILURE); @@ -3195,8 +3355,7 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) return (DDI_FAILURE); } - if (qede_resume(qede) != DDI_SUCCESS) - { + if (qede_resume(qede) != DDI_SUCCESS) { cmn_err(CE_NOTE, "%s:%d resume operation failure\n", __func__, qede->instance); mutex_exit(&qede->drv_lock); @@ -3214,8 +3373,7 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) instance); /* Allocate main structure rounded up to cache line size */ - if ((qede = kmem_zalloc(sizeof(qede_t), KM_SLEEP)) == NULL) - { + if ((qede = kmem_zalloc(sizeof (qede_t), KM_SLEEP)) == NULL) { cmn_err(CE_NOTE, "!%s(%d): Could not allocate adapter " "structure\n", __func__, instance); return (DDI_FAILURE); @@ -3225,7 +3383,7 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) ddi_set_driver_private(dip, qede); qede->dip = dip; qede->instance = instance; - snprintf(qede->name, sizeof(qede->name), "qede%d", instance); + snprintf(qede->name, sizeof (qede->name), "qede%d", instance); edev = &qede->edev; if (qede_config_fm(qede) != DDI_SUCCESS) { @@ -3233,7 +3391,9 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) } qede->attach_resources |= QEDE_FM; - /* Do PCI config setup and map the register and doorbell space */ + /* + * Do PCI config setup and map the register + * and doorbell space */ if (qede_config_pci(qede) != DDI_SUCCESS) { goto exit_with_err; } @@ -3246,7 +3406,7 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) */ mutex_init(&qede->mem_list.mem_list_lock, NULL, MUTEX_DRIVER, 0); - mutex_init(&qede->phys_mem_list.lock , NULL, + mutex_init(&qede->phys_mem_list.lock, NULL, MUTEX_DRIVER, 0); QEDE_INIT_LIST_HEAD(&qede->mem_list.mem_list_head); QEDE_INIT_LIST_HEAD(&qede->phys_mem_list.head); @@ -3287,7 +3447,7 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) #endif qede_cfg_reset(qede); - if (qede_alloc_intrs(qede) ) { + if (qede_alloc_intrs(qede)) { cmn_err(CE_NOTE, "%s: Could not allocate interrupts\n", __func__); goto exit_with_err; @@ -3322,7 +3482,7 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) } qede->attach_resources |= QEDE_EDEV_CONFIG; - if(qede_kstat_init(qede) == B_FALSE) { + if (qede_kstat_init(qede) == B_FALSE) { cmn_err(CE_NOTE, "%s: Could not initialize kstat \n", __func__); goto exit_with_err; @@ -3346,38 +3506,44 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) qede->attach_resources |= QEDE_SP_INTR_ENBL; - cmn_err(CE_NOTE, "qede->attach_resources = %x\n", qede->attach_resources); + cmn_err(CE_NOTE, "qede->attach_resources = %x\n", + qede->attach_resources); - memset((void *)&hw_init_params, 0, sizeof(struct ecore_hw_init_params)); + memset((void *)&hw_init_params, 0, + sizeof (struct ecore_hw_init_params)); hw_init_params.p_drv_load_params = &load_params; - hw_init_params.p_tunn = NULL; /* tunnel params */ - hw_init_params.b_hw_start = true; /* hw_start */ - hw_init_params.int_mode = qede->intr_ctx.intr_mode; /* enum ecore_int_mode */ - hw_init_params.allow_npar_tx_switch = false; /* Allow tx npar switch */ - hw_init_params.bin_fw_data = NULL; /* if NULL, fw_data used from hsi files */ + hw_init_params.p_tunn = NULL; + hw_init_params.b_hw_start = true; + hw_init_params.int_mode = qede->intr_ctx.intr_mode; + hw_init_params.allow_npar_tx_switch = false; + hw_init_params.bin_fw_data = NULL; load_params.is_crash_kernel = false; load_params.mfw_timeout_val = 0; load_params.avoid_eng_reset = false; - load_params.override_force_load = ECORE_OVERRIDE_FORCE_LOAD_NONE; + load_params.override_force_load = + ECORE_OVERRIDE_FORCE_LOAD_NONE; if (ecore_hw_init(edev, &hw_init_params) != ECORE_SUCCESS) { - cmn_err(CE_NOTE, "%s: Could not initialze ecore block\n", __func__); + cmn_err(CE_NOTE, + "%s: Could not initialze ecore block\n", + __func__); goto exit_with_err; } qede->attach_resources |= QEDE_ECORE_HW_INIT; qede->qede_state = QEDE_STATE_ATTACHED; + qede->detach_unsafe = 0; snprintf(qede->version, - sizeof(qede->version), + sizeof (qede->version), "%d.%d.%d", MAJVERSION, MINVERSION, REVVERSION); snprintf(qede->versionFW, - sizeof(qede->versionFW), + sizeof (qede->versionFW), "%d.%d.%d.%d", FW_MAJOR_VERSION, FW_MINOR_VERSION, @@ -3390,9 +3556,11 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) * (test) : saving the default link_input params */ link_params = ecore_mcp_get_link_params(p_hwfn); - memset(&qede->link_input_params, 0, sizeof(qede_link_input_params_t)); - memcpy(&qede->link_input_params.default_link_params, link_params, - sizeof(struct ecore_mcp_link_params)); + memset(&qede->link_input_params, 0, + sizeof (qede_link_input_params_t)); + memcpy(&qede->link_input_params.default_link_params, + link_params, + sizeof (struct ecore_mcp_link_params)); p_hwfn = ECORE_LEADING_HWFN(edev); ecore_mcp_get_mfw_ver(p_hwfn, p_ptt, &qede->mfw_ver, NULL); @@ -3400,7 +3568,7 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) ecore_ptt_release(p_hwfn, p_ptt); snprintf(qede->versionMFW, - sizeof(qede->versionMFW), + sizeof (qede->versionMFW), "%d.%d.%d.%d", (qede->mfw_ver >> 24) & 0xFF, (qede->mfw_ver >> 16) & 0xFF, @@ -3408,12 +3576,12 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) qede->mfw_ver & 0xFF); snprintf(qede->chip_name, - sizeof(qede->chip_name), + sizeof (qede->chip_name), "%s", ECORE_IS_BB(edev) ? "BB" : "AH"); snprintf(qede->chipID, - sizeof(qede->chipID), + sizeof (qede->chipID), "0x%x", qede->edev.chip_num); @@ -3427,13 +3595,16 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) if((rc == DDI_PROP_SUCCESS) && (num_props > 0)) { snprintf(qede->bus_dev_func, - sizeof(qede->bus_dev_func), + sizeof (qede->bus_dev_func), "%04x:%02x:%02x", PCI_REG_BUS_G(props[0]), PCI_REG_DEV_G(props[0]), PCI_REG_FUNC_G(props[0])); - /* This information is used in the QEDE_FUNC_INFO ioctl */ + /* + * This information is used + * in the QEDE_FUNC_INFO ioctl + */ qede->pci_func = (uint8_t) PCI_REG_FUNC_G(props[0]); ddi_prop_free(props); @@ -3455,56 +3626,60 @@ qede_attach(dev_info_t * dip, ddi_attach_cmd_t cmd) snprintf(qede->vendor_device, - sizeof(qede->vendor_device), + sizeof (qede->vendor_device), "%04x:%04x", vendor_id, device_id); snprintf(qede->intrAlloc, - sizeof(qede->intrAlloc), "%d %s", - (qede->intr_ctx.intr_type_in_use == DDI_INTR_TYPE_FIXED) ? 1 : + sizeof (qede->intrAlloc), "%d %s", + (qede->intr_ctx.intr_type_in_use == DDI_INTR_TYPE_FIXED) + ? 1 : qede->intr_ctx.intr_vect_allocated, - (qede->intr_ctx.intr_type_in_use == DDI_INTR_TYPE_MSIX) ? "MSIX" : - (qede->intr_ctx.intr_type_in_use == DDI_INTR_TYPE_MSI) ? "MSI" : "Fixed"); + (qede->intr_ctx.intr_type_in_use == DDI_INTR_TYPE_MSIX) + ? "MSIX" : + (qede->intr_ctx.intr_type_in_use == DDI_INTR_TYPE_MSI) + ? "MSI" : "Fixed"); qede_print("%s(%d): success, addr %p chip %s id %s intr %s\n", - __func__, qede->instance, qede, qede->chip_name, qede->vendor_device,qede->intrAlloc); + __func__, qede->instance, qede, qede->chip_name, + qede->vendor_device,qede->intrAlloc); qede_print("%s(%d): version %s FW %s MFW %s\n", - __func__, qede->instance, qede->version,qede->versionFW, qede->versionMFW); + __func__, qede->instance, qede->version, + qede->versionFW, qede->versionMFW); return (DDI_SUCCESS); } } exit_with_err: - cmn_err(CE_WARN, "%s:%d failed %x\n", __func__, qede->instance, qede->attach_resources); + cmn_err(CE_WARN, "%s:%d failed %x\n", __func__, qede->instance, + qede->attach_resources); (void)qede_free_attach_resources(qede); return (DDI_FAILURE); } -static -int qede_detach(dev_info_t * dip, ddi_detach_cmd_t cmd) +static int +qede_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) { - qede_t * qede; + qede_t *qede; int status; + uint32_t count = 0; qede = (qede_t *)ddi_get_driver_private(dip); - if (qede == NULL || qede->dip != dip) - { + if ((qede == NULL) || (qede->dip != dip)) { return (DDI_FAILURE); } - switch (cmd) - { + switch (cmd) { default: return (DDI_FAILURE); case DDI_SUSPEND: mutex_enter(&qede->drv_lock); status = qede_suspend(qede); - if (status != DDI_SUCCESS) - { + if (status != DDI_SUCCESS) { mutex_exit(&qede->drv_lock); return (DDI_FAILURE); } @@ -3525,77 +3700,30 @@ int qede_detach(dev_info_t * dip, ddi_detach_cmd_t cmd) } } mutex_exit(&qede->drv_lock); + if (qede->detach_unsafe) { + /* + * wait for rx buffers to be returned from + * upper layers + */ + count = 0; + while ((qede->detach_unsafe) && (count < 100)) { + qede_delay(100); + count++; + } + if (qede->detach_unsafe) { + qede_info(qede, "!%s(%d) : Buffers still with" + " OS, failing detach\n", + qede->name, qede->instance); + return (DDI_FAILURE); + } + } qede_free_attach_resources(qede); - return (DDI_SUCCESS); } - - qede->qede_state = QEDE_STATE_FAILED; - mutex_exit(&qede->drv_lock); - return (DDI_FAILURE); -} - - -static int -qede_disable_all_fp_hw_intrs(qede_t *qede) -{ - qede_fastpath_t *fp; - int num_fp, i; - num_fp = qede->num_fp; - if(!num_fp){ - qede_warn(qede, "(%s)%d : no fastpaths?", - __func__, qede->instance); - return (DDI_FAILURE); - } - - for(i = 0; i < num_fp; i++){ - if(!&qede->fp_array[i]){ - qede_warn(qede, "(%s)%d: no fastpath structures!", - __func__, qede->instance); - return (DDI_FAILURE); - } - fp = &qede->fp_array[i]; - - if(!fp->sb_info){ - qede_warn(qede, "(%s)%d: sb_info is NULL!", - __func__, qede->instance); - return (DDI_FAILURE); - } - - ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); - } - return (DDI_SUCCESS); -} - - -static int -qede_disable_hw_intrs(qede_t *qede) -{ - struct ecore_dev *edev = &qede->edev; - struct ecore_hwfn *hwfn; - struct ecore_ptt *ptt = NULL; - int ret; - ret = qede_disable_all_fp_hw_intrs(qede); - if(ret != DDI_SUCCESS){ - qede_warn(qede, "(%s)%d : cannot disable fastpath hw interrupts!", - __func__, qede->instance); - return ret; - } - - hwfn = &edev->hwfns[0]; - ptt = ecore_ptt_acquire(hwfn); - if(ptt == NULL){ - qede_warn(qede, "(%s)%d : Cannot acquire ptt from ecore", - __func__, qede->instance); - } - - ecore_int_igu_disable_int(hwfn, ptt); - - ecore_ptt_release(hwfn, ptt); - return (DDI_SUCCESS); } static int +/* LINTED E_FUNC_ARG_UNUSED */ qede_quiesce(dev_info_t *dip) { qede_t *qede = (qede_t *)ddi_get_driver_private(dip); @@ -3608,35 +3736,12 @@ qede_quiesce(dev_info_t *dip) p_hwfn = ECORE_LEADING_HWFN(edev); p_ptt = ecore_ptt_acquire(p_hwfn); if (p_ptt) { - ecore_start_recovery_process(p_hwfn, p_ptt); + status = ecore_start_recovery_process(p_hwfn, p_ptt); ecore_ptt_release(p_hwfn, p_ptt); OSAL_MSLEEP(5000); } - return status; - -} - - -static int -qede_bus_ctl(dev_info_t * dip, - dev_info_t * pRDev, - ddi_ctl_enum_t op, - void * pArg, - void * pResult) -{ - return 0; -} - + return (status); -static int -qede_cb_ioctl(dev_t dev, - int cmd, - intptr_t arg, - int mode, - cred_t * credp, - int * rvalp) -{ - return (DDI_FAILURE); } @@ -3658,7 +3763,8 @@ static struct modlinkage qede_modlinkage = NULL /* NULL termination */ }; -int _init(void) +int +_init(void) { int rc; @@ -3666,32 +3772,31 @@ int _init(void) mac_init_ops(&qede_dev_ops, "qede"); /* Install module information with O/S */ - if ((rc = mod_install(&qede_modlinkage)) != DDI_SUCCESS) - { + if ((rc = mod_install(&qede_modlinkage)) != DDI_SUCCESS) { mac_fini_ops(&qede_dev_ops); cmn_err(CE_NOTE, "mod_install failed"); - return rc; + return (rc); } - return rc; + return (rc); } -int _fini(void) +int +_fini(void) { int rc; - if ((rc = mod_remove(&qede_modlinkage)) == DDI_SUCCESS) - { + if ((rc = mod_remove(&qede_modlinkage)) == DDI_SUCCESS) { mac_fini_ops(&qede_dev_ops); } - return rc; + return (rc); } int _info(struct modinfo * modinfop) { - return mod_info(&qede_modlinkage, modinfop); + return (mod_info(&qede_modlinkage, modinfop)); } diff --git a/usr/src/uts/common/io/qede/qede_osal.c b/usr/src/uts/common/io/qede/qede_osal.c index 14eaa50c5f..946355bfef 100644 --- a/usr/src/uts/common/io/qede/qede_osal.c +++ b/usr/src/uts/common/io/qede/qede_osal.c @@ -51,6 +51,7 @@ qede_osal_find_dma_handle_for_block(qede_t *qede, void *addr, mutex_enter(&qede->phys_mem_list.lock); QEDE_LIST_FOR_EACH_ENTRY(entry, + /* LINTED E_BAD_PTR_CAST_ALIGN */ &qede->phys_mem_list.head, qede_phys_mem_entry_t, list_entry) { @@ -72,12 +73,12 @@ qede_osal_dma_sync(struct ecore_dev *edev, void* addr, u32 size, bool is_post) qede_t *qede = (qede_t *)edev; qede_phys_mem_entry_t *entry; ddi_dma_handle_t *dma_handle = NULL; - uint_t type = (is_post == false) ? DDI_DMA_SYNC_FORDEV: + uint_t type = (is_post == false) ? DDI_DMA_SYNC_FORDEV : DDI_DMA_SYNC_FORKERNEL; - int i; mutex_enter(&qede->phys_mem_list.lock); - + + /* LINTED E_BAD_PTR_CAST_ALIGN */ QEDE_LIST_FOR_EACH_ENTRY(entry, &qede->phys_mem_list.head, qede_phys_mem_entry_t, list_entry) { if (entry->paddr == addr) { @@ -106,7 +107,7 @@ qede_osal_zalloc(struct ecore_dev *edev, int flags, size_t size) qede_mem_list_entry_t *new_entry; void *buf; - if ((new_entry = kmem_zalloc(sizeof(qede_mem_list_entry_t), flags)) + if ((new_entry = kmem_zalloc(sizeof (qede_mem_list_entry_t), flags)) == NULL) { qede_print_err("%s(%d): Failed to alloc new list entry", __func__, qede->instance); @@ -138,7 +139,7 @@ qede_osal_alloc(struct ecore_dev *edev, int flags, size_t size) qede_mem_list_entry_t *new_entry; void *buf; - if ((new_entry = kmem_zalloc(sizeof(qede_mem_list_entry_t), flags)) + if ((new_entry = kmem_zalloc(sizeof (qede_mem_list_entry_t), flags)) == NULL) { qede_print_err("%s(%d): Failed to alloc new list entry", __func__, qede->instance); @@ -170,10 +171,12 @@ qede_osal_free(struct ecore_dev *edev, void *addr) mutex_enter(&qede->mem_list.mem_list_lock); + /* LINTED E_BAD_PTR_CAST_ALIGN */ QEDE_LIST_FOR_EACH_ENTRY(mem_entry, &qede->mem_list.mem_list_head, qede_mem_list_entry_t, mem_entry) { if (mem_entry->buf == addr) { - QEDE_LIST_REMOVE(&mem_entry->mem_entry, &qede->mem_list.mem_list_head); + QEDE_LIST_REMOVE(&mem_entry->mem_entry, + &qede->mem_list.mem_list_head); kmem_free(addr, mem_entry->size); kmem_free(mem_entry, sizeof (qede_mem_list_entry_t)); break; @@ -187,7 +190,8 @@ qede_osal_free(struct ecore_dev *edev, void *addr) * @VB: What are the alignment requirements here ?? */ void * -qede_osal_dma_alloc_coherent(struct ecore_dev *edev, dma_addr_t *paddr, size_t size) +qede_osal_dma_alloc_coherent(struct ecore_dev *edev, dma_addr_t *paddr, + size_t size) { qede_t *qede = (qede_t *)edev; qede_phys_mem_entry_t *new_entry; @@ -200,7 +204,8 @@ qede_osal_dma_alloc_coherent(struct ecore_dev *edev, dma_addr_t *paddr, size_t s memset(&cookie, 0, sizeof (cookie)); - if ((new_entry = kmem_zalloc(sizeof (qede_phys_mem_entry_t), KM_NOSLEEP)) == NULL) { + if ((new_entry = + kmem_zalloc(sizeof (qede_phys_mem_entry_t), KM_NOSLEEP)) == NULL) { qede_print_err("%s(%d): Failed to alloc new list entry", __func__, qede->instance); return (NULL); @@ -209,7 +214,9 @@ qede_osal_dma_alloc_coherent(struct ecore_dev *edev, dma_addr_t *paddr, size_t s dma_handle = &new_entry->dma_handle; dma_acc_handle = &new_entry->dma_acc_handle; - if ((ret = ddi_dma_alloc_handle(qede->dip, &qede_gen_buf_dma_attr, DDI_DMA_DONTWAIT, + if ((ret = + ddi_dma_alloc_handle(qede->dip, &qede_gen_buf_dma_attr, + DDI_DMA_DONTWAIT, NULL, dma_handle)) != DDI_SUCCESS) { qede_print_err("%s(%d): Failed to alloc dma handle", __func__, qede->instance); @@ -218,16 +225,19 @@ qede_osal_dma_alloc_coherent(struct ecore_dev *edev, dma_addr_t *paddr, size_t s } if ((ret = ddi_dma_mem_alloc(*dma_handle, size, &qede_desc_acc_attr, - DDI_DMA_CONSISTENT, DDI_DMA_DONTWAIT, NULL, &pbuf, &size, dma_acc_handle)) != DDI_SUCCESS) { + DDI_DMA_CONSISTENT, DDI_DMA_DONTWAIT, NULL, &pbuf, &size, + dma_acc_handle)) != DDI_SUCCESS) { qede_print_err("%s(%d): Failed to alloc dma mem %d bytes", __func__, qede->instance, size); qede_stacktrace(qede); goto free_hdl; } - if ((ret = ddi_dma_addr_bind_handle(*dma_handle, NULL, pbuf, size, DDI_DMA_RDWR | DDI_DMA_CONSISTENT, + if ((ret = ddi_dma_addr_bind_handle(*dma_handle, NULL, pbuf, size, + DDI_DMA_RDWR | DDI_DMA_CONSISTENT, DDI_DMA_DONTWAIT, NULL, &cookie, &count)) != DDI_DMA_MAPPED) { - qede_print("!%s(%d): failed to bind dma addr to handle, ret %d", + qede_print("!%s(%d): failed to bind dma addr to handle," + " ret %d", __func__, qede->instance, ret); goto free_dma_mem; } @@ -245,7 +255,6 @@ qede_osal_dma_alloc_coherent(struct ecore_dev *edev, dma_addr_t *paddr, size_t s new_entry->paddr = (void *)cookie.dmac_laddress; *paddr = (dma_addr_t)new_entry->paddr; - /*qede_print("osal_dmal qede %p %d *paddr %p virt %p\n", qede, qede->instance, *paddr, pbuf);*/ mutex_enter(&qede->phys_mem_list.lock); QEDE_LIST_ADD(&new_entry->list_entry, &qede->phys_mem_list.head); @@ -262,7 +271,8 @@ free: return (NULL); } -void qede_osal_dma_free_coherent(struct ecore_dev *edev, void *vaddr, +void +qede_osal_dma_free_coherent(struct ecore_dev *edev, void *vaddr, dma_addr_t paddr, size_t size) { qede_t *qede = (qede_t *)edev; @@ -270,10 +280,12 @@ void qede_osal_dma_free_coherent(struct ecore_dev *edev, void *vaddr, mutex_enter(&qede->phys_mem_list.lock); + /* LINTED E_BAD_PTR_CAST_ALIGN */ QEDE_LIST_FOR_EACH_ENTRY(entry, &qede->phys_mem_list.head, qede_phys_mem_entry_t, list_entry) { if (entry->virt_addr == vaddr) { - QEDE_LIST_REMOVE(&entry->list_entry, &qede->phys_mem_list.head); + QEDE_LIST_REMOVE(&entry->list_entry, + &qede->phys_mem_list.head); ddi_dma_unbind_handle(entry->dma_handle); ddi_dma_mem_free(&entry->dma_acc_handle); ddi_dma_free_handle(&entry->dma_handle); @@ -285,7 +297,8 @@ void qede_osal_dma_free_coherent(struct ecore_dev *edev, void *vaddr, mutex_exit(&qede->phys_mem_list.lock); } -static int qede_get_port_type(uint32_t media_type) +static int +qede_get_port_type(uint32_t media_type) { uint32_t port_type; @@ -308,7 +321,7 @@ static int qede_get_port_type(uint32_t media_type) port_type = GLDM_UNKNOWN; break; } - return port_type; + return (port_type); } void @@ -324,98 +337,136 @@ qede_get_link_info(struct ecore_hwfn *hwfn, struct qede_link_cfg *lnkCfg) ecore_mcp_get_media_type(edev, &media_type); lnkCfg->port = qede_get_port_type(media_type); - memcpy(&lnk_state, ecore_mcp_get_link_state(hwfn), sizeof(lnk_state)); - memcpy(&lnk_params, ecore_mcp_get_link_params(hwfn), sizeof(lnk_params)); - memcpy(&lnk_caps, ecore_mcp_get_link_capabilities(hwfn), sizeof(lnk_caps)); + memcpy(&lnk_state, ecore_mcp_get_link_state(hwfn), + sizeof (lnk_state)); + memcpy(&lnk_params, ecore_mcp_get_link_params(hwfn), + sizeof (lnk_params)); + memcpy(&lnk_caps, ecore_mcp_get_link_capabilities(hwfn), + sizeof (lnk_caps)); - if(lnk_state.link_up) { + if (lnk_state.link_up) { lnkCfg->link_up = B_TRUE; lnkCfg->speed = lnk_state.speed; lnkCfg->duplex = DUPLEX_FULL; } - if(lnk_params.speed.autoneg) { + if (lnk_params.speed.autoneg) { lnkCfg->supp_capab.autoneg = B_TRUE; lnkCfg->adv_capab.autoneg = B_TRUE; } - if(lnk_params.speed.autoneg || + if (lnk_params.speed.autoneg || (lnk_params.pause.forced_rx && lnk_params.pause.forced_tx)) { lnkCfg->supp_capab.asym_pause = B_TRUE; lnkCfg->adv_capab.asym_pause = B_TRUE; } - if(lnk_params.speed.autoneg || + if (lnk_params.speed.autoneg || lnk_params.pause.forced_rx || lnk_params.pause.forced_tx) { lnkCfg->supp_capab.pause = B_TRUE; lnkCfg->adv_capab.pause = B_TRUE; } - if(lnk_params.speed.advertised_speeds & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_10G) + if (lnk_params.speed.advertised_speeds & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_10G) { lnkCfg->adv_capab.param_10000fdx = B_TRUE; - if(lnk_params.speed.advertised_speeds & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_25G) - lnkCfg->adv_capab.param_25000fdx = B_TRUE; - if(lnk_params.speed.advertised_speeds & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_40G) + } + if(lnk_params.speed.advertised_speeds & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_25G) { + lnkCfg->adv_capab.param_25000fdx = B_TRUE; + } + if (lnk_params.speed.advertised_speeds & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_40G) { lnkCfg->adv_capab.param_40000fdx = B_TRUE; - if(lnk_params.speed.advertised_speeds & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_50G) + } + if (lnk_params.speed.advertised_speeds & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_50G) { lnkCfg->adv_capab.param_50000fdx = B_TRUE; - if(lnk_params.speed.advertised_speeds & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_BB_100G) + } + if (lnk_params.speed.advertised_speeds & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_BB_100G) { lnkCfg->adv_capab.param_100000fdx = B_TRUE; - if(lnk_params.speed.advertised_speeds & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_1G) { + } + if (lnk_params.speed.advertised_speeds & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_1G) { lnkCfg->adv_capab.param_1000fdx = B_TRUE; lnkCfg->adv_capab.param_1000hdx = B_TRUE; } lnkCfg->autoneg = lnk_params.speed.autoneg; - if(lnk_caps.speed_capabilities & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_10G) + if (lnk_caps.speed_capabilities & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_10G) { lnkCfg->supp_capab.param_10000fdx = B_TRUE; - if(lnk_caps.speed_capabilities & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_10G) - lnkCfg->supp_capab.param_25000fdx = B_TRUE; - if(lnk_caps.speed_capabilities & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_40G) + } + if(lnk_caps.speed_capabilities & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_25G) { + lnkCfg->supp_capab.param_25000fdx = B_TRUE; + } + if (lnk_caps.speed_capabilities & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_40G) { lnkCfg->supp_capab.param_40000fdx = B_TRUE; - if(lnk_caps.speed_capabilities & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_50G) + } + if (lnk_caps.speed_capabilities & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_50G) { lnkCfg->supp_capab.param_50000fdx = B_TRUE; - if(lnk_caps.speed_capabilities & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_BB_100G) + } + if (lnk_caps.speed_capabilities & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_BB_100G) { lnkCfg->supp_capab.param_100000fdx = B_TRUE; - if(lnk_caps.speed_capabilities & NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_1G) { + } + if (lnk_caps.speed_capabilities & + NVM_CFG1_PORT_DRV_SPEED_CAPABILITY_MASK_1G) { lnkCfg->supp_capab.param_1000fdx = B_TRUE; lnkCfg->supp_capab.param_1000hdx = B_TRUE; } - if (lnk_params.pause.autoneg) + if (lnk_params.pause.autoneg) { lnkCfg->pause_cfg |= QEDE_LINK_PAUSE_AUTONEG_ENABLE; - if (lnk_params.pause.forced_rx) + } + if (lnk_params.pause.forced_rx) { lnkCfg->pause_cfg |= QEDE_LINK_PAUSE_RX_ENABLE; - if (lnk_params.pause.forced_tx) + } + if (lnk_params.pause.forced_tx) { lnkCfg->pause_cfg |= QEDE_LINK_PAUSE_TX_ENABLE; + } if(lnk_state.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_1G_HD) + ECORE_LINK_PARTNER_SPEED_1G_HD) { lnkCfg->rem_capab.param_1000hdx = B_TRUE; + } if(lnk_state.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_1G_FD) + ECORE_LINK_PARTNER_SPEED_1G_FD) { lnkCfg->rem_capab.param_1000fdx = B_TRUE; + } if(lnk_state.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_10G) + ECORE_LINK_PARTNER_SPEED_10G) { lnkCfg->rem_capab.param_10000fdx = B_TRUE; + } if(lnk_state.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_40G) + ECORE_LINK_PARTNER_SPEED_40G) { lnkCfg->rem_capab.param_40000fdx = B_TRUE; + } if(lnk_state.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_50G) + ECORE_LINK_PARTNER_SPEED_50G) { lnkCfg->rem_capab.param_50000fdx = B_TRUE; + } if(lnk_state.partner_adv_speed & - ECORE_LINK_PARTNER_SPEED_100G) + ECORE_LINK_PARTNER_SPEED_100G) { lnkCfg->rem_capab.param_100000fdx = B_TRUE; + } - if(lnk_state.an_complete) - lnkCfg->rem_capab.autoneg = B_TRUE; + if(lnk_state.an_complete) { + lnkCfg->rem_capab.autoneg = B_TRUE; + } - if(lnk_state.partner_adv_pause) - lnkCfg->rem_capab.pause = B_TRUE; - if(lnk_state.partner_adv_pause == ECORE_LINK_PARTNER_ASYMMETRIC_PAUSE || - lnk_state.partner_adv_pause == ECORE_LINK_PARTNER_BOTH_PAUSE) - lnkCfg->rem_capab.asym_pause = B_TRUE; + if(lnk_state.partner_adv_pause) { + lnkCfg->rem_capab.pause = B_TRUE; + } + if(lnk_state.partner_adv_pause == + ECORE_LINK_PARTNER_ASYMMETRIC_PAUSE || + lnk_state.partner_adv_pause == ECORE_LINK_PARTNER_BOTH_PAUSE) { + lnkCfg->rem_capab.asym_pause = B_TRUE; + } } void @@ -425,7 +476,7 @@ qede_osal_link_update(struct ecore_hwfn *hwfn) qede_t *qede = (qede_t *)(void *)edev; struct qede_link_cfg link_cfg; - memset(&link_cfg, 0 , sizeof(struct qede_link_cfg)); + memset(&link_cfg, 0 , sizeof (struct qede_link_cfg)); qede_get_link_info(hwfn, &link_cfg); if (link_cfg.duplex == DUPLEX_FULL) { @@ -450,26 +501,29 @@ qede_osal_link_update(struct ecore_hwfn *hwfn) qede->params.link_state = 1; qede->props.link_speed = link_cfg.speed; qede->props.link_duplex = link_cfg.duplex; - qede->props.tx_pause = (link_cfg.pause_cfg & QEDE_LINK_PAUSE_TX_ENABLE) ? B_TRUE : B_FALSE; - qede->props.rx_pause = (link_cfg.pause_cfg & QEDE_LINK_PAUSE_RX_ENABLE) ? B_TRUE : B_FALSE; + qede->props.tx_pause = (link_cfg.pause_cfg & + QEDE_LINK_PAUSE_TX_ENABLE) ? B_TRUE : B_FALSE; + qede->props.rx_pause = (link_cfg.pause_cfg & + QEDE_LINK_PAUSE_RX_ENABLE) ? B_TRUE : B_FALSE; qede->props.uptime = ddi_get_time(); mac_link_update(qede->mac_handle, LINK_STATE_UP); } } -unsigned long log2_align(unsigned long n) +unsigned long +log2_align(unsigned long n) { unsigned long ret = n ? 1 : 0; unsigned long _n = n >> 1; - while (_n) - { + while (_n) { _n >>= 1; ret <<= 1; } - if (ret < n) + if (ret < n) { ret <<= 1; + } return (ret); } @@ -477,7 +531,7 @@ unsigned long log2_align(unsigned long n) u32 LOG2(u32 v) { - u32 r=0; + u32 r = 0; while (v >>= 1) { r++; } @@ -485,6 +539,7 @@ LOG2(u32 v) } int +/* LINTED E_FUNC_ARG_UNUSED */ qede_osal_pci_find_ext_capab(struct ecore_dev *edev, u16 pcie_id) { int offset = 0; @@ -539,7 +594,7 @@ qede_osal_pci_bar2_write32(struct ecore_hwfn *hwfn, u32 offset, u32 val) u64 addr = qede->pci_bar2_base; addr += offset; - ddi_put32(qede->doorbell_handle , (u32 *)addr, val); + ddi_put32(qede->doorbell_handle, (u32 *)addr, val); } u32 @@ -570,7 +625,7 @@ qede_osal_reg_addr(struct ecore_hwfn *hwfn, u32 addr) } void -qede_osal_pci_read_config_byte(struct ecore_dev *edev, u32 addr, u8 *val) +qede_osal_pci_read_config_byte(struct ecore_dev *edev, u32 addr, u8 *val) { qede_t *qede = (qede_t *)edev; @@ -579,7 +634,7 @@ qede_osal_pci_read_config_byte(struct ecore_dev *edev, u32 addr, u8 *val) } void -qede_osal_pci_read_config_word(struct ecore_dev *edev, u32 addr, u16 *val) +qede_osal_pci_read_config_word(struct ecore_dev *edev, u32 addr, u16 *val) { qede_t *qede = (qede_t *)edev; @@ -587,7 +642,7 @@ qede_osal_pci_read_config_word(struct ecore_dev *edev, u32 addr, u16 *val) } void -qede_osal_pci_read_config_dword(struct ecore_dev *edev, u32 addr, u32 *val) +qede_osal_pci_read_config_dword(struct ecore_dev *edev, u32 addr, u32 *val) { qede_t *qede = (qede_t *)edev; @@ -595,7 +650,8 @@ qede_osal_pci_read_config_dword(struct ecore_dev *edev, u32 addr, u32 *val) } -void qede_print(char *format, ...) +void +qede_print(char *format, ...) { va_list ap; @@ -604,7 +660,8 @@ void qede_print(char *format, ...) va_end(ap); } -void qede_print_err(char *format, ...) +void +qede_print_err(char *format, ...) { va_list ap; @@ -642,6 +699,7 @@ qede_osal_cleanup(qede_t *qede) QEDE_LIST_FOR_EACH_ENTRY_SAFE(entry, temp, + /* LINTED E_BAD_PTR_CAST_ALIGN */ &qede->mem_list.mem_list_head, mem_entry, qede_mem_list_entry_t) { @@ -670,6 +728,7 @@ qede_osal_cleanup(qede_t *qede) QEDE_LIST_FOR_EACH_ENTRY_SAFE(entry_phys, temp_phys, + /* LINTED E_BAD_PTR_CAST_ALIGN */ &qede->phys_mem_list.head, list_entry, qede_phys_mem_entry_t) { @@ -700,80 +759,95 @@ qede_osal_recovery_handler(struct ecore_hwfn *hwfn) struct ecore_dev *edev = (struct ecore_dev *)hwfn->p_dev; qede_t *qede = (qede_t *)(void *)edev; - qede_warn(qede, "Not implemented !"); + cmn_err(CE_WARN, "!%s(%d):Not implemented !", + __func__, qede->instance); + } -enum _ecore_status_t qede_osal_iov_vf_acquire(struct ecore_hwfn *p_hwfn, int vf_id) +enum _ecore_status_t +qede_osal_iov_vf_acquire(struct ecore_hwfn *p_hwfn, int vf_id) { return (ECORE_SUCCESS); } -void qede_osal_pci_write_config_word(struct ecore_dev *dev, u32 addr, u16 pcie_id) +void +qede_osal_pci_write_config_word(struct ecore_dev *dev, u32 addr, u16 pcie_id) { qede_t *qede = (qede_t *)dev; ddi_acc_handle_t pci_cfg_handle = qede->pci_cfg_handle; pci_config_put16(pci_cfg_handle, (off_t)addr, pcie_id); - return; } -void * qede_osal_valloc(struct ecore_dev *dev, u32 size) +void * +qede_osal_valloc(struct ecore_dev *dev, u32 size) { - return (NULL); + void *ptr = 0; + + return (ptr); } -void qede_osal_vfree(struct ecore_dev *dev, void* mem) +void +qede_osal_vfree(struct ecore_dev *dev, void* mem) { - return; } -int qede_osal_pci_find_capability(struct ecore_dev *dev, u16 pcie_id) +int +/* LINTED E_FUNC_ARG_UNUSED */ +qede_osal_pci_find_capability(struct ecore_dev *dev, u16 pcie_id) { return 1; } -void qede_osal_poll_mode_dpc(struct ecore_hwfn *p_hwfn) +void +qede_osal_poll_mode_dpc(struct ecore_hwfn *p_hwfn) { - return; } -int qede_osal_bitmap_weight(unsigned long *bitmap, uint32_t nbits) +int +/* LINTED E_FUNC_ARG_UNUSED */ +qede_osal_bitmap_weight(unsigned long *bitmap, uint32_t nbits) { uint32_t count = 0, temp = *bitmap; - /*while(temp) { - count += temp & 1; - temp >> 1; - } - nbits = count;*/ return count; } -void qede_osal_mfw_tlv_req(struct ecore_hwfn *p_hwfn) +void +/* LINTED E_FUNC_ARG_UNUSED */ +qede_osal_mfw_tlv_req(struct ecore_hwfn *p_hwfn) { - return; } -u32 qede_osal_crc32(u32 crc, u8 *buf, u64 length) +u32 +/* LINTED E_FUNC_ARG_UNUSED */ +qede_osal_crc32(u32 crc, u8 *buf, u64 length) { return 1; } -void qede_osal_hw_info_change(struct ecore_hwfn *p_hwfn, int change) +void +/* LINTED E_FUNC_ARG_UNUSED */ +qede_osal_hw_info_change(struct ecore_hwfn *p_hwfn, int change) { - return; } -void OSAL_CRC8_POPULATE(u8 * cdu_crc8_table, u8 polynomial) +void +/* LINTED E_FUNC_ARG_UNUSED */ +OSAL_CRC8_POPULATE(u8 * cdu_crc8_table, u8 polynomial) { - return; } -u8 OSAL_CRC8(u8 * cdu_crc8_table, u8 * data_to_crc, int data_to_crc_len, u8 init_value) +u8 +/* LINTED E_FUNC_ARG_UNUSED */ +OSAL_CRC8(u8 * cdu_crc8_table, u8 * data_to_crc, int data_to_crc_len, + u8 init_value) { - return ECORE_NOTIMPL; + return (0); } -void OSAL_DPC_SYNC(struct ecore_hwfn *p_hwfn) +void +/* LINTED E_FUNC_ARG_UNUSED */ +OSAL_DPC_SYNC(struct ecore_hwfn *p_hwfn) { //Do nothing right now. } diff --git a/usr/src/uts/common/io/qede/qede_types.h b/usr/src/uts/common/io/qede/qede_types.h index 4f0d875374..88fdb16da7 100644 --- a/usr/src/uts/common/io/qede/qede_types.h +++ b/usr/src/uts/common/io/qede/qede_types.h @@ -33,6 +33,9 @@ * limitations under the License. */ +#ifndef _QEDE_TYPES_H +#define _QEDE_TYPES_H + typedef uint8_t u8; typedef uint8_t U8; typedef uint16_t u16; @@ -65,3 +68,5 @@ typedef u64 dma_addr_t; * requirement */ typedef u64 osal_uintptr_t; + +#endif /* !_QEDE_TYPES_H */ diff --git a/usr/src/uts/common/io/qede/qede_version.h b/usr/src/uts/common/io/qede/qede_version.h index a8844ddc50..59ac6cdd65 100644 --- a/usr/src/uts/common/io/qede/qede_version.h +++ b/usr/src/uts/common/io/qede/qede_version.h @@ -34,6 +34,11 @@ */ +#ifndef _QEDE_VERSION_H +#define _QEDE_VERSION_H + #define MAJVERSION 8 #define MINVERSION 0 -#define REVVERSION 22 +#define REVVERSION 23 + +#endif /* !_QEDE_VERSION_H */ diff --git a/usr/src/uts/intel/Makefile b/usr/src/uts/intel/Makefile index 3187cc28e9..1f873651ec 100644 --- a/usr/src/uts/intel/Makefile +++ b/usr/src/uts/intel/Makefile @@ -33,7 +33,8 @@ include Makefile.intel LINT_KMODS_X1 = $(LINT_KMODS:nsmb=) LINT_KMODS_X2 = $(LINT_KMODS_X1:smbfs=) LINT_KMODS_X3 = $(LINT_KMODS_X2:e1000g=) -LINT_KMODLIBS = $(LINT_KMODS_X3:iwn=) +LINT_KMODS_X4 = $(LINT_KMODS_X3:qede=) +LINT_KMODLIBS = $(LINT_KMODS_X4:iwn=) LINT_LIBS = $(LINT_LIB) $(GEN_LINT_LIB) \ $(LINT_KMODLIBS:%=$(LINT_LIB_DIR)/llib-l%.ln) diff --git a/usr/src/uts/intel/qede/Makefile b/usr/src/uts/intel/qede/Makefile index 58ae26951b..088ac3b41d 100644 --- a/usr/src/uts/intel/qede/Makefile +++ b/usr/src/uts/intel/qede/Makefile @@ -17,7 +17,6 @@ UTSBASE = ../.. MODULE = qede OBJECTS = $(QEDE_OBJS:%=$(OBJS_DIR)/%) $(QEDE_GEN_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(QEDE_OBJS:%.o=$(LINTS_DIR)/%.ln) ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) CONF_SRCDIR = $(UTSBASE)/common/io/qede @@ -50,17 +49,23 @@ CERRWARN += -_gcc=-Wno-unused-variable CERRWARN += -_gcc=-Wno-unused-function ALL_TARGET = $(BINARY) $(CONFMOD) +<<<<<<< HEAD LINT_TARGET = $(MODULE).lint +======= +>>>>>>> FETCH_HEAD INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) LDFLAGS += -dy -N misc/mac +<<<<<<< HEAD # # We only support the 64-bit version of this driver. # DEF_BUILDS = $(DEF_BUILDSONLY64) ALL_BUILDS = $(ALL_BUILDSONLY64) +======= +>>>>>>> FETCH_HEAD .KEEP_STATE: def: $(DEF_DEPS) @@ -71,11 +76,17 @@ clean: $(CLEAN_DEPS) clobber: $(CLOBBER_DEPS) +<<<<<<< HEAD lint: $(LINT_DEPS) modlintlib: $(MODLINTLIB_DEPS) clean.lint: $(CLEAN_LINT_DEPS) +======= +lint: +modlintlib: +clean.lint: +>>>>>>> FETCH_HEAD install: $(INSTALL_DEPS) |