aq(4): Style, whitespace and misc cleanup
The compiled objects do not change other than a few diagnostic messages that include __LINE__. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54304
This commit is contained in:
+9
-17
@@ -37,14 +37,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define s8 __int8_t
|
||||
#define u8 __uint8_t
|
||||
#define u16 __uint16_t
|
||||
#define s16 __int16_t
|
||||
#define u32 __uint32_t
|
||||
#define u64 __uint64_t
|
||||
#define s64 __int64_t
|
||||
#define s32 int
|
||||
|
||||
#define ETIME ETIMEDOUT
|
||||
#define EOK 0
|
||||
@@ -59,18 +51,18 @@
|
||||
#endif
|
||||
|
||||
#define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \
|
||||
do { \
|
||||
do { \
|
||||
unsigned int i; \
|
||||
for (i = _N_; (!(_B_)) && i; --i) { \
|
||||
usec_delay(_US_); \
|
||||
} \
|
||||
if (!i) { \
|
||||
err = -1; \
|
||||
} \
|
||||
} while (0)
|
||||
for (i = _N_; (!(_B_)) && i; --i) { \
|
||||
usec_delay(_US_); \
|
||||
} \
|
||||
if (!i) { \
|
||||
err = -1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LOWORD(a) ((u16)(a))
|
||||
#define LOWORD(a) ((uint16_t)(a))
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#define AQ_VER "0.0.5"
|
||||
|
||||
+50
-45
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
|
||||
const aq_debug_level dbg_level_ = lvl_detail;
|
||||
const u32 dbg_categories_ = dbg_init | dbg_config | dbg_fw;
|
||||
const uint32_t dbg_categories_ = dbg_init | dbg_config | dbg_fw;
|
||||
|
||||
|
||||
|
||||
@@ -55,24 +55,25 @@ const u32 dbg_categories_ = dbg_init | dbg_config | dbg_fw;
|
||||
(BIT(BIT_BEGIN - BIT_END + 1) -1))
|
||||
|
||||
#define __field(TYPE, VAR) TYPE VAR;
|
||||
void trace_aq_tx_descr(int ring_idx, unsigned int pointer, volatile u64 descr[2])
|
||||
void
|
||||
trace_aq_tx_descr(int ring_idx, unsigned int pointer, volatile uint64_t descr[2])
|
||||
{
|
||||
#if AQ_CFG_DEBUG_LVL > 2
|
||||
struct __entry{
|
||||
__field(unsigned int, ring_idx)
|
||||
__field(unsigned int, pointer)
|
||||
/* Tx Descriptor */
|
||||
__field(u64, data_buf_addr)
|
||||
__field(u32, pay_len)
|
||||
__field(u8, ct_en)
|
||||
__field(u8, ct_idx)
|
||||
__field(u16, rsvd2)
|
||||
__field(u8, tx_cmd)
|
||||
__field(u8, eop)
|
||||
__field(u8, dd)
|
||||
__field(u16, buf_len)
|
||||
__field(u8, rsvd1)
|
||||
__field(u8, des_typ)
|
||||
__field(uint64_t, data_buf_addr)
|
||||
__field(uint32_t, pay_len)
|
||||
__field(uint8_t, ct_en)
|
||||
__field(uint8_t, ct_idx)
|
||||
__field(uint16_t, rsvd2)
|
||||
__field(uint8_t, tx_cmd)
|
||||
__field(uint8_t, eop)
|
||||
__field(uint8_t, dd)
|
||||
__field(uint16_t, buf_len)
|
||||
__field(uint8_t, rsvd1)
|
||||
__field(uint8_t, des_typ)
|
||||
} entry;
|
||||
|
||||
entry.ring_idx = ring_idx;
|
||||
@@ -98,27 +99,28 @@ void trace_aq_tx_descr(int ring_idx, unsigned int pointer, volatile u64 descr[2]
|
||||
#endif
|
||||
}
|
||||
|
||||
void trace_aq_rx_descr(int ring_idx, unsigned int pointer, volatile u64 descr[2])
|
||||
void
|
||||
trace_aq_rx_descr(int ring_idx, unsigned int pointer, volatile uint64_t descr[2])
|
||||
{
|
||||
#if AQ_CFG_DEBUG_LVL > 2
|
||||
u8 dd;
|
||||
u8 eop;
|
||||
u8 rx_stat;
|
||||
u8 rx_estat;
|
||||
u8 rsc_cnt;
|
||||
u16 pkt_len;
|
||||
u16 next_desp;
|
||||
u16 vlan_tag;
|
||||
uint8_t dd;
|
||||
uint8_t eop;
|
||||
uint8_t rx_stat;
|
||||
uint8_t rx_estat;
|
||||
uint8_t rsc_cnt;
|
||||
uint16_t pkt_len;
|
||||
uint16_t next_desp;
|
||||
uint16_t vlan_tag;
|
||||
|
||||
u8 rss_type;
|
||||
u8 pkt_type;
|
||||
u8 rdm_err;
|
||||
u8 avb_ts;
|
||||
u8 rsvd;
|
||||
u8 rx_cntl;
|
||||
u8 sph;
|
||||
u16 hdr_len;
|
||||
u32 rss_hash;
|
||||
uint8_t rss_type;
|
||||
uint8_t pkt_type;
|
||||
uint8_t rdm_err;
|
||||
uint8_t avb_ts;
|
||||
uint8_t rsvd;
|
||||
uint8_t rx_cntl;
|
||||
uint8_t sph;
|
||||
uint16_t hdr_len;
|
||||
uint32_t rss_hash;
|
||||
|
||||
rss_hash = DESCR_FIELD(descr[0], 63, 32);
|
||||
hdr_len = DESCR_FIELD(descr[0], 31, 22);
|
||||
@@ -149,24 +151,26 @@ void trace_aq_rx_descr(int ring_idx, unsigned int pointer, volatile u64 descr[2]
|
||||
#endif
|
||||
}
|
||||
|
||||
void trace_aq_tx_context_descr(int ring_idx, unsigned int pointer, volatile u64 descr[2])
|
||||
void
|
||||
trace_aq_tx_context_descr(int ring_idx, unsigned int pointer,
|
||||
volatile uint64_t descr[2])
|
||||
{
|
||||
#if AQ_CFG_DEBUG_LVL > 2
|
||||
struct __entry_s{
|
||||
__field(unsigned int, ring_idx)
|
||||
__field(unsigned int, pointer)
|
||||
/* Tx Context Descriptor */
|
||||
__field(u16, out_len)
|
||||
__field(u8, tun_len)
|
||||
__field(u64, resvd3)
|
||||
__field(u16, mss_len)
|
||||
__field(u8, l4_len)
|
||||
__field(u8, l3_len)
|
||||
__field(u8, l2_len)
|
||||
__field(u8, ct_cmd)
|
||||
__field(u16, vlan_tag)
|
||||
__field(u8, ct_idx)
|
||||
__field(u8, des_typ)
|
||||
__field(uint16_t, out_len)
|
||||
__field(uint8_t, tun_len)
|
||||
__field(uint64_t, resvd3)
|
||||
__field(uint16_t, mss_len)
|
||||
__field(uint8_t, l4_len)
|
||||
__field(uint8_t, l3_len)
|
||||
__field(uint8_t, l2_len)
|
||||
__field(uint8_t, ct_cmd)
|
||||
__field(uint16_t, vlan_tag)
|
||||
__field(uint8_t, ct_idx)
|
||||
__field(uint8_t, des_typ)
|
||||
} entry;
|
||||
struct __entry_s *__entry = &entry;
|
||||
__entry->ring_idx = ring_idx;
|
||||
@@ -192,7 +196,8 @@ void trace_aq_tx_context_descr(int ring_idx, unsigned int pointer, volatile u64
|
||||
#endif
|
||||
}
|
||||
|
||||
void DumpHex(const void* data, size_t size) {
|
||||
void
|
||||
DumpHex(const void* data, size_t size) {
|
||||
#if AQ_CFG_DEBUG_LVL > 3
|
||||
char ascii[17];
|
||||
size_t i, j;
|
||||
@@ -234,4 +239,4 @@ void DumpHex(const void* data, size_t size) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
+19
-19
@@ -38,8 +38,8 @@
|
||||
#ifndef AQ_DBG_H
|
||||
#define AQ_DBG_H
|
||||
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/syslog.h>
|
||||
/*
|
||||
Debug levels:
|
||||
0 - no debug
|
||||
@@ -78,10 +78,10 @@ Debug levels:
|
||||
|
||||
#if AQ_CFG_DEBUG_LVL > 2
|
||||
#define AQ_DBG_DUMP_DESC(desc) { \
|
||||
volatile u8 *raw = (volatile u8*)(desc); \
|
||||
printf( "07-00 %02X%02X%02X%02X %02X%02X%02X%02X 15-08 %02X%02X%02X%02X %02X%02X%02X%02X\n", \
|
||||
raw[7], raw[6], raw[5], raw[4], raw[3], raw[2], raw[1], raw[0], \
|
||||
raw[15], raw[14], raw[13], raw[12], raw[11], raw[10], raw[9], raw[8]); \
|
||||
volatile uint8_t *raw = (volatile uint8_t*)(desc); \
|
||||
printf( "07-00 %02X%02X%02X%02X %02X%02X%02X%02X 15-08 %02X%02X%02X%02X %02X%02X%02X%02X\n", \
|
||||
raw[7], raw[6], raw[5], raw[4], raw[3], raw[2], raw[1], raw[0], \
|
||||
raw[15], raw[14], raw[13], raw[12], raw[11], raw[10], raw[9], raw[8]); \
|
||||
}\
|
||||
|
||||
#else
|
||||
@@ -90,27 +90,27 @@ Debug levels:
|
||||
|
||||
typedef enum aq_debug_level
|
||||
{
|
||||
lvl_error = LOG_ERR,
|
||||
lvl_warn = LOG_WARNING,
|
||||
lvl_trace = LOG_NOTICE,
|
||||
lvl_detail = LOG_INFO,
|
||||
lvl_error = LOG_ERR,
|
||||
lvl_warn = LOG_WARNING,
|
||||
lvl_trace = LOG_NOTICE,
|
||||
lvl_detail = LOG_INFO,
|
||||
} aq_debug_level;
|
||||
|
||||
typedef enum aq_debug_category
|
||||
{
|
||||
dbg_init = 1,
|
||||
dbg_config = 1 << 1,
|
||||
dbg_tx = 1 << 2,
|
||||
dbg_rx = 1 << 3,
|
||||
dbg_intr = 1 << 4,
|
||||
dbg_fw = 1 << 5,
|
||||
dbg_init = 1,
|
||||
dbg_config = 1 << 1,
|
||||
dbg_tx = 1 << 2,
|
||||
dbg_rx = 1 << 3,
|
||||
dbg_intr = 1 << 4,
|
||||
dbg_fw = 1 << 5,
|
||||
} aq_debug_category;
|
||||
|
||||
|
||||
#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
extern const aq_debug_level dbg_level_;
|
||||
extern const u32 dbg_categories_;
|
||||
extern const uint32_t dbg_categories_;
|
||||
|
||||
#define log_base_(_lvl, _fmt, args...) printf( "atlantic: " _fmt "\n", ##args)
|
||||
|
||||
@@ -130,9 +130,9 @@ extern const u32 dbg_categories_;
|
||||
#define trace(_cat, _fmt, args...) trace_base_(lvl_trace, _cat, _fmt, ##args)
|
||||
#define trace_detail(_cat, _fmt, args...) trace_base_(lvl_detail, _cat, _fmt, ##args)
|
||||
|
||||
void trace_aq_tx_descr(int ring_idx, unsigned int pointer, volatile u64 descr[2]);
|
||||
void trace_aq_rx_descr(int ring_idx, unsigned int pointer, volatile u64 descr[2]);
|
||||
void trace_aq_tx_context_descr(int ring_idx, unsigned int pointer, volatile u64 descr[2]);
|
||||
void trace_aq_tx_descr(int ring_idx, unsigned int pointer, volatile uint64_t descr[2]);
|
||||
void trace_aq_rx_descr(int ring_idx, unsigned int pointer, volatile uint64_t descr[2]);
|
||||
void trace_aq_tx_context_descr(int ring_idx, unsigned int pointer, volatile uint64_t descr[2]);
|
||||
void DumpHex(const void* data, size_t size);
|
||||
|
||||
#endif // AQ_DBG_H
|
||||
|
||||
+29
-29
@@ -54,40 +54,40 @@ enum aq_media_type {
|
||||
AQ_LINK_10G )
|
||||
|
||||
struct aq_stats_s {
|
||||
u64 prc;
|
||||
u64 uprc;
|
||||
u64 mprc;
|
||||
u64 bprc;
|
||||
u64 cprc;
|
||||
u64 erpr;
|
||||
u64 dpc;
|
||||
u64 brc;
|
||||
u64 ubrc;
|
||||
u64 mbrc;
|
||||
u64 bbrc;
|
||||
uint64_t prc;
|
||||
uint64_t uprc;
|
||||
uint64_t mprc;
|
||||
uint64_t bprc;
|
||||
uint64_t cprc;
|
||||
uint64_t erpr;
|
||||
uint64_t dpc;
|
||||
uint64_t brc;
|
||||
uint64_t ubrc;
|
||||
uint64_t mbrc;
|
||||
uint64_t bbrc;
|
||||
|
||||
u64 ptc;
|
||||
u64 uptc;
|
||||
u64 mptc;
|
||||
u64 bptc;
|
||||
u64 erpt;
|
||||
u64 btc;
|
||||
u64 ubtc;
|
||||
u64 mbtc;
|
||||
u64 bbtc;
|
||||
uint64_t ptc;
|
||||
uint64_t uptc;
|
||||
uint64_t mptc;
|
||||
uint64_t bptc;
|
||||
uint64_t erpt;
|
||||
uint64_t btc;
|
||||
uint64_t ubtc;
|
||||
uint64_t mbtc;
|
||||
uint64_t bbtc;
|
||||
};
|
||||
|
||||
enum aq_dev_state_e {
|
||||
AQ_DEV_STATE_UNLOAD,
|
||||
AQ_DEV_STATE_PCI_STOP,
|
||||
AQ_DEV_STATE_DOWN,
|
||||
AQ_DEV_STATE_UP,
|
||||
AQ_DEV_STATE_UNLOAD,
|
||||
AQ_DEV_STATE_PCI_STOP,
|
||||
AQ_DEV_STATE_DOWN,
|
||||
AQ_DEV_STATE_UP,
|
||||
};
|
||||
|
||||
struct aq_rx_filters {
|
||||
unsigned int rule_cnt;
|
||||
struct aq_rx_filter_vlan vlan_filters[AQ_HW_VLAN_MAX_FILTERS];
|
||||
struct aq_rx_filter_l2 etype_filters[AQ_HW_ETYPE_MAX_FILTERS];
|
||||
unsigned int rule_cnt;
|
||||
struct aq_rx_filter_vlan vlan_filters[AQ_HW_VLAN_MAX_FILTERS];
|
||||
struct aq_rx_filter_l2 etype_filters[AQ_HW_ETYPE_MAX_FILTERS];
|
||||
};
|
||||
|
||||
struct aq_vlan_tag {
|
||||
@@ -102,7 +102,7 @@ struct aq_dev {
|
||||
if_shared_ctx_t sctx;
|
||||
struct ifmedia * media;
|
||||
|
||||
struct aq_hw hw;
|
||||
struct aq_hw hw;
|
||||
|
||||
enum aq_media_type media_type;
|
||||
uint32_t link_speeds;
|
||||
@@ -142,7 +142,7 @@ int aq_update_hw_stats(aq_dev_t *aq_dev);
|
||||
void aq_initmedia(aq_dev_t *aq_dev);
|
||||
int aq_linkstat_isr(void *arg);
|
||||
int aq_isr_rx(void *arg);
|
||||
void aq_mediastatus_update(aq_dev_t *aq_dev, u32 link_speed, const struct aq_hw_fc_info *fc_neg);
|
||||
void aq_mediastatus_update(aq_dev_t *aq_dev, uint32_t link_speed, const struct aq_hw_fc_info *fc_neg);
|
||||
void aq_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr);
|
||||
int aq_mediachange(struct ifnet *ifp);
|
||||
void aq_if_update_admin_status(if_ctx_t ctx);
|
||||
|
||||
+219
-209
@@ -55,10 +55,10 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
typedef enum aq_fw_bootloader_mode
|
||||
{
|
||||
boot_mode_unknown = 0,
|
||||
boot_mode_flb,
|
||||
boot_mode_rbl_flash,
|
||||
boot_mode_rbl_host_bootload,
|
||||
boot_mode_unknown = 0,
|
||||
boot_mode_flb,
|
||||
boot_mode_rbl_flash,
|
||||
boot_mode_rbl_host_bootload,
|
||||
} aq_fw_bootloader_mode;
|
||||
|
||||
#define AQ_CFG_HOST_BOOT_DISABLE 0
|
||||
@@ -67,22 +67,22 @@ typedef enum aq_fw_bootloader_mode
|
||||
#define MAC_FW_START_TIMEOUT_MS 10000
|
||||
#define FW_LOADER_START_TIMEOUT_MS 10000
|
||||
|
||||
const u32 NO_RESET_SCRATCHPAD_ADDRESS = 0;
|
||||
const u32 NO_RESET_SCRATCHPAD_LEN_RES = 1;
|
||||
const u32 NO_RESET_SCRATCHPAD_RBL_STATUS = 2;
|
||||
const u32 NO_RESET_SCRATCHPAD_RBL_STATUS_2 = 3;
|
||||
const u32 WRITE_DATA_COMPLETE = 0x55555555;
|
||||
const u32 WRITE_DATA_CHUNK_DONE = 0xaaaaaaaa;
|
||||
const u32 WRITE_DATA_FAIL_WRONG_ADDRESS = 0x66666666;
|
||||
const uint32_t NO_RESET_SCRATCHPAD_ADDRESS = 0;
|
||||
const uint32_t NO_RESET_SCRATCHPAD_LEN_RES = 1;
|
||||
const uint32_t NO_RESET_SCRATCHPAD_RBL_STATUS = 2;
|
||||
const uint32_t NO_RESET_SCRATCHPAD_RBL_STATUS_2 = 3;
|
||||
const uint32_t WRITE_DATA_COMPLETE = 0x55555555;
|
||||
const uint32_t WRITE_DATA_CHUNK_DONE = 0xaaaaaaaa;
|
||||
const uint32_t WRITE_DATA_FAIL_WRONG_ADDRESS = 0x66666666;
|
||||
|
||||
const u32 WAIT_WRITE_TIMEOUT = 1;
|
||||
const u32 WAIT_WRITE_TIMEOUT_COUNT = 1000;
|
||||
const uint32_t WAIT_WRITE_TIMEOUT = 1;
|
||||
const uint32_t WAIT_WRITE_TIMEOUT_COUNT = 1000;
|
||||
|
||||
const u32 RBL_STATUS_SUCCESS = 0xabba;
|
||||
const u32 RBL_STATUS_FAILURE = 0xbad;
|
||||
const u32 RBL_STATUS_HOST_BOOT = 0xf1a7;
|
||||
const uint32_t RBL_STATUS_SUCCESS = 0xabba;
|
||||
const uint32_t RBL_STATUS_FAILURE = 0xbad;
|
||||
const uint32_t RBL_STATUS_HOST_BOOT = 0xf1a7;
|
||||
|
||||
const u32 SCRATCHPAD_FW_LOADER_STATUS = (0x40 / sizeof(u32));
|
||||
const uint32_t SCRATCHPAD_FW_LOADER_STATUS = (0x40 / sizeof(uint32_t));
|
||||
|
||||
|
||||
extern struct aq_firmware_ops aq_fw1x_ops;
|
||||
@@ -95,258 +95,268 @@ int mac_soft_reset_rbl_(struct aq_hw* hw, aq_fw_bootloader_mode* mode);
|
||||
int wait_init_mac_firmware_(struct aq_hw* hw);
|
||||
|
||||
|
||||
int aq_fw_reset(struct aq_hw* hw)
|
||||
int
|
||||
aq_fw_reset(struct aq_hw* hw)
|
||||
{
|
||||
int ver = AQ_READ_REG(hw, 0x18);
|
||||
u32 bootExitCode = 0;
|
||||
int k;
|
||||
int ver = AQ_READ_REG(hw, 0x18);
|
||||
uint32_t bootExitCode = 0;
|
||||
int k;
|
||||
|
||||
for (k = 0; k < 1000; ++k) {
|
||||
u32 flbStatus = reg_glb_daisy_chain_status1_get(hw);
|
||||
bootExitCode = AQ_READ_REG(hw, 0x388);
|
||||
if (flbStatus != 0x06000000 || bootExitCode != 0)
|
||||
break;
|
||||
}
|
||||
for (k = 0; k < 1000; ++k) {
|
||||
uint32_t flbStatus = reg_glb_daisy_chain_status1_get(hw);
|
||||
bootExitCode = AQ_READ_REG(hw, 0x388);
|
||||
if (flbStatus != 0x06000000 || bootExitCode != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (k == 1000) {
|
||||
aq_log_error("Neither RBL nor FLB started");
|
||||
return (-EBUSY);
|
||||
}
|
||||
if (k == 1000) {
|
||||
aq_log_error("Neither RBL nor FLB started");
|
||||
return (-EBUSY);
|
||||
}
|
||||
|
||||
hw->rbl_enabled = bootExitCode != 0;
|
||||
hw->rbl_enabled = bootExitCode != 0;
|
||||
|
||||
trace(dbg_init, "RBL enabled = %d", hw->rbl_enabled);
|
||||
trace(dbg_init, "RBL enabled = %d", hw->rbl_enabled);
|
||||
|
||||
/* Having FW version 0 is an indicator that cold start
|
||||
* is in progress. This means two things:
|
||||
* 1) Driver have to wait for FW/HW to finish boot (500ms giveup)
|
||||
* 2) Driver may skip reset sequence and save time.
|
||||
*/
|
||||
if (hw->fast_start_enabled && !ver) {
|
||||
int err = wait_init_mac_firmware_(hw);
|
||||
/* Skip reset as it just completed */
|
||||
if (!err)
|
||||
return (0);
|
||||
}
|
||||
/* Having FW version 0 is an indicator that cold start
|
||||
* is in progress. This means two things:
|
||||
* 1) Driver have to wait for FW/HW to finish boot (500ms giveup)
|
||||
* 2) Driver may skip reset sequence and save time.
|
||||
*/
|
||||
if (hw->fast_start_enabled && !ver) {
|
||||
int err = wait_init_mac_firmware_(hw);
|
||||
/* Skip reset as it just completed */
|
||||
if (!err)
|
||||
return (0);
|
||||
}
|
||||
|
||||
aq_fw_bootloader_mode mode = boot_mode_unknown;
|
||||
int err = mac_soft_reset_(hw, &mode);
|
||||
if (err < 0) {
|
||||
aq_log_error("MAC reset failed: %d", err);
|
||||
return (err);
|
||||
}
|
||||
aq_fw_bootloader_mode mode = boot_mode_unknown;
|
||||
int err = mac_soft_reset_(hw, &mode);
|
||||
if (err < 0) {
|
||||
aq_log_error("MAC reset failed: %d", err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case boot_mode_flb:
|
||||
aq_log("FLB> F/W successfully loaded from flash.");
|
||||
hw->flash_present = true;
|
||||
return wait_init_mac_firmware_(hw);
|
||||
switch (mode) {
|
||||
case boot_mode_flb:
|
||||
aq_log("FLB> F/W successfully loaded from flash.");
|
||||
hw->flash_present = true;
|
||||
return wait_init_mac_firmware_(hw);
|
||||
|
||||
case boot_mode_rbl_flash:
|
||||
aq_log("RBL> F/W loaded from flash. Host Bootload disabled.");
|
||||
hw->flash_present = true;
|
||||
return wait_init_mac_firmware_(hw);
|
||||
case boot_mode_rbl_flash:
|
||||
aq_log("RBL> F/W loaded from flash. Host Bootload disabled.");
|
||||
hw->flash_present = true;
|
||||
return wait_init_mac_firmware_(hw);
|
||||
|
||||
case boot_mode_unknown:
|
||||
aq_log_error("F/W bootload error: unknown bootloader type");
|
||||
return (-ENOTSUP);
|
||||
case boot_mode_unknown:
|
||||
aq_log_error("F/W bootload error: unknown bootloader type");
|
||||
return (-ENOTSUP);
|
||||
|
||||
case boot_mode_rbl_host_bootload:
|
||||
case boot_mode_rbl_host_bootload:
|
||||
#if AQ_CFG_HOST_BOOT_DISABLE
|
||||
aq_log_error("RBL> Host Bootload mode: this driver does not support Host Boot");
|
||||
return (-ENOTSUP);
|
||||
aq_log_error("RBL> Host Bootload mode: this driver does not support Host Boot");
|
||||
return (-ENOTSUP);
|
||||
#else
|
||||
trace(dbg_init, "RBL> Host Bootload mode");
|
||||
break;
|
||||
trace(dbg_init, "RBL> Host Bootload mode");
|
||||
break;
|
||||
#endif // HOST_BOOT_DISABLE
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* #todo: Host Boot
|
||||
*/
|
||||
aq_log_error("RBL> F/W Host Bootload not implemented");
|
||||
/*
|
||||
* #todo: Host Boot
|
||||
*/
|
||||
aq_log_error("RBL> F/W Host Bootload not implemented");
|
||||
|
||||
return (-ENOTSUP);
|
||||
return (-ENOTSUP);
|
||||
}
|
||||
|
||||
int aq_fw_ops_init(struct aq_hw* hw)
|
||||
int
|
||||
aq_fw_ops_init(struct aq_hw* hw)
|
||||
{
|
||||
if (hw->fw_version.raw == 0)
|
||||
hw->fw_version.raw = AQ_READ_REG(hw, 0x18);
|
||||
if (hw->fw_version.raw == 0)
|
||||
hw->fw_version.raw = AQ_READ_REG(hw, 0x18);
|
||||
|
||||
aq_log("MAC F/W version is %d.%d.%d",
|
||||
hw->fw_version.major_version, hw->fw_version.minor_version,
|
||||
hw->fw_version.build_number);
|
||||
aq_log("MAC F/W version is %d.%d.%d",
|
||||
hw->fw_version.major_version, hw->fw_version.minor_version,
|
||||
hw->fw_version.build_number);
|
||||
|
||||
if (hw->fw_version.major_version == 1) {
|
||||
trace(dbg_init, "using F/W ops v1.x");
|
||||
hw->fw_ops = &aq_fw1x_ops;
|
||||
return (EOK);
|
||||
} else if (hw->fw_version.major_version >= 2) {
|
||||
trace(dbg_init, "using F/W ops v2.x");
|
||||
hw->fw_ops = &aq_fw2x_ops;
|
||||
return (EOK);
|
||||
}
|
||||
if (hw->fw_version.major_version == 1) {
|
||||
trace(dbg_init, "using F/W ops v1.x");
|
||||
hw->fw_ops = &aq_fw1x_ops;
|
||||
return (EOK);
|
||||
} else if (hw->fw_version.major_version >= 2) {
|
||||
trace(dbg_init, "using F/W ops v2.x");
|
||||
hw->fw_ops = &aq_fw2x_ops;
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
aq_log_error("aq_fw_ops_init(): invalid F/W version %#x", hw->fw_version.raw);
|
||||
return (-ENOTSUP);
|
||||
aq_log_error("aq_fw_ops_init(): invalid F/W version %#x",
|
||||
hw->fw_version.raw);
|
||||
return (-ENOTSUP);
|
||||
}
|
||||
|
||||
|
||||
int mac_soft_reset_(struct aq_hw* hw, aq_fw_bootloader_mode* mode /*= nullptr*/)
|
||||
int
|
||||
mac_soft_reset_(struct aq_hw* hw, aq_fw_bootloader_mode* mode /*= nullptr*/)
|
||||
{
|
||||
if (hw->rbl_enabled) {
|
||||
return mac_soft_reset_rbl_(hw, mode);
|
||||
} else {
|
||||
if (mode)
|
||||
*mode = boot_mode_flb;
|
||||
if (hw->rbl_enabled) {
|
||||
return mac_soft_reset_rbl_(hw, mode);
|
||||
} else {
|
||||
if (mode)
|
||||
*mode = boot_mode_flb;
|
||||
|
||||
return mac_soft_reset_flb_(hw);
|
||||
}
|
||||
return mac_soft_reset_flb_(hw);
|
||||
}
|
||||
}
|
||||
|
||||
int mac_soft_reset_flb_(struct aq_hw* hw)
|
||||
int
|
||||
mac_soft_reset_flb_(struct aq_hw* hw)
|
||||
{
|
||||
int k;
|
||||
int k;
|
||||
|
||||
reg_global_ctl2_set(hw, 0x40e1);
|
||||
// Let Felicity hardware to complete SMBUS transaction before Global software reset.
|
||||
msec_delay(50);
|
||||
reg_global_ctl2_set(hw, 0x40e1);
|
||||
// Let Felicity hardware to complete SMBUS transaction before Global software reset.
|
||||
msec_delay(50);
|
||||
|
||||
/*
|
||||
* If SPI burst transaction was interrupted(before running the script), global software
|
||||
* reset may not clear SPI interface. Clean it up manually before global reset.
|
||||
*/
|
||||
reg_glb_nvr_provisioning2_set(hw, 0xa0);
|
||||
reg_glb_nvr_interface1_set(hw, 0x9f);
|
||||
reg_glb_nvr_interface1_set(hw, 0x809f);
|
||||
msec_delay(50);
|
||||
/*
|
||||
* If SPI burst transaction was interrupted(before running the script), global software
|
||||
* reset may not clear SPI interface. Clean it up manually before global reset.
|
||||
*/
|
||||
reg_glb_nvr_provisioning2_set(hw, 0xa0);
|
||||
reg_glb_nvr_interface1_set(hw, 0x9f);
|
||||
reg_glb_nvr_interface1_set(hw, 0x809f);
|
||||
msec_delay(50);
|
||||
|
||||
reg_glb_standard_ctl1_set(hw, (reg_glb_standard_ctl1_get(hw) & ~glb_reg_res_dis_msk) | glb_soft_res_msk);
|
||||
reg_glb_standard_ctl1_set(hw, (reg_glb_standard_ctl1_get(hw) & ~glb_reg_res_dis_msk) | glb_soft_res_msk);
|
||||
|
||||
// Kickstart.
|
||||
reg_global_ctl2_set(hw, 0x80e0);
|
||||
reg_mif_power_gating_enable_control_set(hw, 0);
|
||||
if (!hw->fast_start_enabled)
|
||||
reg_glb_general_provisioning9_set(hw, 1);
|
||||
// Kickstart.
|
||||
reg_global_ctl2_set(hw, 0x80e0);
|
||||
reg_mif_power_gating_enable_control_set(hw, 0);
|
||||
if (!hw->fast_start_enabled)
|
||||
reg_glb_general_provisioning9_set(hw, 1);
|
||||
|
||||
/*
|
||||
* For the case SPI burst transaction was interrupted (by MCP reset above),
|
||||
* wait until it is completed by hardware.
|
||||
*/
|
||||
msec_delay(50); // Sleep for 10 ms.
|
||||
/*
|
||||
* For the case SPI burst transaction was interrupted (by MCP reset above),
|
||||
* wait until it is completed by hardware.
|
||||
*/
|
||||
msec_delay(50); // Sleep for 10 ms.
|
||||
|
||||
/* MAC Kickstart */
|
||||
if (!hw->fast_start_enabled) {
|
||||
reg_global_ctl2_set(hw, 0x180e0);
|
||||
/* MAC Kickstart */
|
||||
if (!hw->fast_start_enabled) {
|
||||
reg_global_ctl2_set(hw, 0x180e0);
|
||||
|
||||
u32 flb_status = 0;
|
||||
int k;
|
||||
for (k = 0; k < 1000; ++k) {
|
||||
flb_status = reg_glb_daisy_chain_status1_get(hw) & 0x10;
|
||||
if (flb_status != 0)
|
||||
break;
|
||||
msec_delay(10); // Sleep for 10 ms.
|
||||
}
|
||||
uint32_t flb_status = 0;
|
||||
int k;
|
||||
for (k = 0; k < 1000; ++k) {
|
||||
flb_status = reg_glb_daisy_chain_status1_get(hw) & 0x10;
|
||||
if (flb_status != 0)
|
||||
break;
|
||||
msec_delay(10); // Sleep for 10 ms.
|
||||
}
|
||||
|
||||
if (flb_status == 0) {
|
||||
trace_error(dbg_init, "FLB> MAC kickstart failed: timed out");
|
||||
return (false);
|
||||
}
|
||||
if (flb_status == 0) {
|
||||
trace_error(dbg_init,
|
||||
"FLB> MAC kickstart failed: timed out");
|
||||
return (false);
|
||||
}
|
||||
|
||||
trace(dbg_init, "FLB> MAC kickstart done, %d ms", k);
|
||||
/* FW reset */
|
||||
reg_global_ctl2_set(hw, 0x80e0);
|
||||
// Let Felicity hardware complete SMBUS transaction before Global software reset.
|
||||
msec_delay(50);
|
||||
}
|
||||
reg_glb_cpu_sem_set(hw, 1, 0);
|
||||
trace(dbg_init, "FLB> MAC kickstart done, %d ms", k);
|
||||
/* FW reset */
|
||||
reg_global_ctl2_set(hw, 0x80e0);
|
||||
// Let Felicity hardware complete SMBUS transaction before Global software reset.
|
||||
msec_delay(50);
|
||||
}
|
||||
reg_glb_cpu_sem_set(hw, 1, 0);
|
||||
|
||||
// PHY Kickstart: #undone
|
||||
// PHY Kickstart: #undone
|
||||
|
||||
// Global software reset
|
||||
rx_rx_reg_res_dis_set(hw, 0);
|
||||
tx_tx_reg_res_dis_set(hw, 0);
|
||||
mpi_tx_reg_res_dis_set(hw, 0);
|
||||
reg_glb_standard_ctl1_set(hw, (reg_glb_standard_ctl1_get(hw) & ~glb_reg_res_dis_msk) | glb_soft_res_msk);
|
||||
// Global software reset
|
||||
rx_rx_reg_res_dis_set(hw, 0);
|
||||
tx_tx_reg_res_dis_set(hw, 0);
|
||||
mpi_tx_reg_res_dis_set(hw, 0);
|
||||
reg_glb_standard_ctl1_set(hw, (reg_glb_standard_ctl1_get(hw) & ~glb_reg_res_dis_msk) | glb_soft_res_msk);
|
||||
|
||||
bool restart_completed = false;
|
||||
for (k = 0; k < 1000; ++k) {
|
||||
restart_completed = reg_glb_fw_image_id1_get(hw) != 0;
|
||||
if (restart_completed)
|
||||
break;
|
||||
msec_delay(10);
|
||||
}
|
||||
bool restart_completed = false;
|
||||
for (k = 0; k < 1000; ++k) {
|
||||
restart_completed = reg_glb_fw_image_id1_get(hw) != 0;
|
||||
if (restart_completed)
|
||||
break;
|
||||
msec_delay(10);
|
||||
}
|
||||
|
||||
if (!restart_completed) {
|
||||
trace_error(dbg_init, "FLB> Global Soft Reset failed");
|
||||
return (false);
|
||||
}
|
||||
if (!restart_completed) {
|
||||
trace_error(dbg_init, "FLB> Global Soft Reset failed");
|
||||
return (false);
|
||||
}
|
||||
|
||||
trace(dbg_init, "FLB> F/W restart: %d ms", k * 10);
|
||||
return (true);
|
||||
trace(dbg_init, "FLB> F/W restart: %d ms", k * 10);
|
||||
return (true);
|
||||
}
|
||||
|
||||
int mac_soft_reset_rbl_(struct aq_hw* hw, aq_fw_bootloader_mode* mode)
|
||||
int
|
||||
mac_soft_reset_rbl_(struct aq_hw* hw, aq_fw_bootloader_mode* mode)
|
||||
{
|
||||
trace(dbg_init, "RBL> MAC reset STARTED!");
|
||||
trace(dbg_init, "RBL> MAC reset STARTED!");
|
||||
|
||||
reg_global_ctl2_set(hw, 0x40e1);
|
||||
reg_glb_cpu_sem_set(hw, 1, 0);
|
||||
reg_mif_power_gating_enable_control_set(hw, 0);
|
||||
reg_global_ctl2_set(hw, 0x40e1);
|
||||
reg_glb_cpu_sem_set(hw, 1, 0);
|
||||
reg_mif_power_gating_enable_control_set(hw, 0);
|
||||
|
||||
// MAC FW will reload PHY FW if 1E.1000.3 was cleaned - #undone
|
||||
// MAC FW will reload PHY FW if 1E.1000.3 was cleaned - #undone
|
||||
|
||||
reg_glb_cpu_no_reset_scratchpad_set(hw, 0xDEAD, NO_RESET_SCRATCHPAD_RBL_STATUS);
|
||||
reg_glb_cpu_no_reset_scratchpad_set(hw, 0xDEAD,
|
||||
NO_RESET_SCRATCHPAD_RBL_STATUS);
|
||||
|
||||
// Global software reset
|
||||
rx_rx_reg_res_dis_set(hw, 0);
|
||||
tx_tx_reg_res_dis_set(hw, 0);
|
||||
mpi_tx_reg_res_dis_set(hw, 0);
|
||||
reg_glb_standard_ctl1_set(hw, (reg_glb_standard_ctl1_get(hw) & ~glb_reg_res_dis_msk) | glb_soft_res_msk);
|
||||
// Global software reset
|
||||
rx_rx_reg_res_dis_set(hw, 0);
|
||||
tx_tx_reg_res_dis_set(hw, 0);
|
||||
mpi_tx_reg_res_dis_set(hw, 0);
|
||||
reg_glb_standard_ctl1_set(hw, (reg_glb_standard_ctl1_get(hw) & ~glb_reg_res_dis_msk) | glb_soft_res_msk);
|
||||
|
||||
reg_global_ctl2_set(hw, 0x40e0);
|
||||
reg_global_ctl2_set(hw, 0x40e0);
|
||||
|
||||
// Wait for RBL to finish boot process.
|
||||
u16 rbl_status = 0;
|
||||
for (int k = 0; k < RBL_TIMEOUT_MS; ++k) {
|
||||
rbl_status = LOWORD(reg_glb_cpu_no_reset_scratchpad_get(hw, NO_RESET_SCRATCHPAD_RBL_STATUS));
|
||||
if (rbl_status != 0 && rbl_status != 0xDEAD)
|
||||
break;
|
||||
// Wait for RBL to finish boot process.
|
||||
uint16_t rbl_status = 0;
|
||||
for (int k = 0; k < RBL_TIMEOUT_MS; ++k) {
|
||||
rbl_status = LOWORD(reg_glb_cpu_no_reset_scratchpad_get(hw, NO_RESET_SCRATCHPAD_RBL_STATUS));
|
||||
if (rbl_status != 0 && rbl_status != 0xDEAD)
|
||||
break;
|
||||
|
||||
msec_delay(1);
|
||||
}
|
||||
msec_delay(1);
|
||||
}
|
||||
|
||||
if (rbl_status == 0 || rbl_status == 0xDEAD) {
|
||||
trace_error(dbg_init, "RBL> RBL restart failed: timeout");
|
||||
return (-EBUSY);
|
||||
}
|
||||
if (rbl_status == 0 || rbl_status == 0xDEAD) {
|
||||
trace_error(dbg_init, "RBL> RBL restart failed: timeout");
|
||||
return (-EBUSY);
|
||||
}
|
||||
|
||||
if (rbl_status == RBL_STATUS_SUCCESS) {
|
||||
if (mode)
|
||||
*mode = boot_mode_rbl_flash;
|
||||
trace(dbg_init, "RBL> reset complete! [Flash]");
|
||||
} else if (rbl_status == RBL_STATUS_HOST_BOOT) {
|
||||
if (mode)
|
||||
*mode = boot_mode_rbl_host_bootload;
|
||||
trace(dbg_init, "RBL> reset complete! [Host Bootload]");
|
||||
} else {
|
||||
trace_error(dbg_init, "unknown RBL status 0x%x", rbl_status);
|
||||
return (-EBUSY);
|
||||
}
|
||||
if (rbl_status == RBL_STATUS_SUCCESS) {
|
||||
if (mode)
|
||||
*mode = boot_mode_rbl_flash;
|
||||
trace(dbg_init, "RBL> reset complete! [Flash]");
|
||||
} else if (rbl_status == RBL_STATUS_HOST_BOOT) {
|
||||
if (mode)
|
||||
*mode = boot_mode_rbl_host_bootload;
|
||||
trace(dbg_init, "RBL> reset complete! [Host Bootload]");
|
||||
} else {
|
||||
trace_error(dbg_init, "unknown RBL status 0x%x", rbl_status);
|
||||
return (-EBUSY);
|
||||
}
|
||||
|
||||
return (EOK);
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
int wait_init_mac_firmware_(struct aq_hw* hw)
|
||||
int
|
||||
wait_init_mac_firmware_(struct aq_hw* hw)
|
||||
{
|
||||
for (int i = 0; i < MAC_FW_START_TIMEOUT_MS; ++i) {
|
||||
if ((hw->fw_version.raw = AQ_READ_REG(hw, 0x18)) != 0)
|
||||
return (EOK);
|
||||
for (int i = 0; i < MAC_FW_START_TIMEOUT_MS; ++i) {
|
||||
if ((hw->fw_version.raw = AQ_READ_REG(hw, 0x18)) != 0)
|
||||
return (EOK);
|
||||
|
||||
msec_delay(1);
|
||||
}
|
||||
msec_delay(1);
|
||||
}
|
||||
|
||||
trace_error(dbg_init, "timeout waiting for reg 0x18. MAC f/w NOT READY");
|
||||
return (-EBUSY);
|
||||
trace_error(dbg_init,
|
||||
"timeout waiting for reg 0x18. MAC f/w NOT READY");
|
||||
return (-EBUSY);
|
||||
}
|
||||
|
||||
+18
-17
@@ -38,35 +38,36 @@ struct aq_hw;
|
||||
|
||||
typedef enum aq_fw_link_speed
|
||||
{
|
||||
aq_fw_none = 0,
|
||||
aq_fw_100M = (1 << 0),
|
||||
aq_fw_1G = (1 << 1),
|
||||
aq_fw_2G5 = (1 << 2),
|
||||
aq_fw_5G = (1 << 3),
|
||||
aq_fw_10G = (1 << 4),
|
||||
aq_fw_none = 0,
|
||||
aq_fw_100M = (1 << 0),
|
||||
aq_fw_1G = (1 << 1),
|
||||
aq_fw_2G5 = (1 << 2),
|
||||
aq_fw_5G = (1 << 3),
|
||||
aq_fw_10G = (1 << 4),
|
||||
} aq_fw_link_speed_t;
|
||||
|
||||
typedef enum aq_fw_link_fc
|
||||
{
|
||||
aq_fw_fc_none = 0,
|
||||
aq_fw_fc_ENABLE_RX = BIT(0),
|
||||
aq_fw_fc_ENABLE_TX = BIT(1),
|
||||
aq_fw_fc_ENABLE_ALL = aq_fw_fc_ENABLE_RX | aq_fw_fc_ENABLE_TX,
|
||||
aq_fw_fc_none = 0,
|
||||
aq_fw_fc_ENABLE_RX = BIT(0),
|
||||
aq_fw_fc_ENABLE_TX = BIT(1),
|
||||
aq_fw_fc_ENABLE_ALL = aq_fw_fc_ENABLE_RX | aq_fw_fc_ENABLE_TX,
|
||||
} aq_fw_link_fc_t;
|
||||
|
||||
#define aq_fw_speed_auto (aq_fw_100M | aq_fw_1G | aq_fw_2G5 | aq_fw_5G | aq_fw_10G)
|
||||
#define aq_fw_speed_auto \
|
||||
(aq_fw_100M | aq_fw_1G | aq_fw_2G5 | aq_fw_5G | aq_fw_10G)
|
||||
|
||||
struct aq_firmware_ops
|
||||
{
|
||||
int (*reset)(struct aq_hw* hal);
|
||||
int (*reset)(struct aq_hw* hal);
|
||||
|
||||
int (*set_mode)(struct aq_hw* hal, enum aq_hw_fw_mpi_state_e mode, aq_fw_link_speed_t speed);
|
||||
int (*get_mode)(struct aq_hw* hal, enum aq_hw_fw_mpi_state_e* mode, aq_fw_link_speed_t* speed, aq_fw_link_fc_t* fc);
|
||||
int (*set_mode)(struct aq_hw* hal, enum aq_hw_fw_mpi_state_e mode, aq_fw_link_speed_t speed);
|
||||
int (*get_mode)(struct aq_hw* hal, enum aq_hw_fw_mpi_state_e* mode, aq_fw_link_speed_t* speed, aq_fw_link_fc_t* fc);
|
||||
|
||||
int (*get_mac_addr)(struct aq_hw* hal, u8* mac_addr);
|
||||
int (*get_stats)(struct aq_hw* hal, struct aq_hw_stats_s* stats);
|
||||
int (*get_mac_addr)(struct aq_hw* hal, uint8_t* mac_addr);
|
||||
int (*get_stats)(struct aq_hw* hal, struct aq_hw_stats_s* stats);
|
||||
|
||||
int (*led_control)(struct aq_hw* hal, u32 mode);
|
||||
int (*led_control)(struct aq_hw* hal, uint32_t mode);
|
||||
};
|
||||
|
||||
|
||||
|
||||
+191
-180
@@ -31,7 +31,7 @@
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@@ -50,264 +50,275 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
|
||||
typedef enum fw1x_mode {
|
||||
FW1X_MPI_DEINIT = 0,
|
||||
FW1X_MPI_RESERVED = 1,
|
||||
FW1X_MPI_INIT = 2,
|
||||
FW1X_MPI_POWER = 4,
|
||||
FW1X_MPI_DEINIT = 0,
|
||||
FW1X_MPI_RESERVED = 1,
|
||||
FW1X_MPI_INIT = 2,
|
||||
FW1X_MPI_POWER = 4,
|
||||
} fw1x_mode;
|
||||
|
||||
typedef enum aq_fw1x_rate {
|
||||
FW1X_RATE_10G = 1 << 0,
|
||||
FW1X_RATE_5G = 1 << 1,
|
||||
FW1X_RATE_5GSR = 1 << 2,
|
||||
FW1X_RATE_2G5 = 1 << 3,
|
||||
FW1X_RATE_1G = 1 << 4,
|
||||
FW1X_RATE_100M = 1 << 5,
|
||||
FW1X_RATE_INVALID = 1 << 6,
|
||||
FW1X_RATE_10G = 1 << 0,
|
||||
FW1X_RATE_5G = 1 << 1,
|
||||
FW1X_RATE_5GSR = 1 << 2,
|
||||
FW1X_RATE_2G5 = 1 << 3,
|
||||
FW1X_RATE_1G = 1 << 4,
|
||||
FW1X_RATE_100M = 1 << 5,
|
||||
FW1X_RATE_INVALID = 1 << 6,
|
||||
} aq_fw1x_rate;
|
||||
|
||||
typedef union fw1x_state_reg {
|
||||
u32 val;
|
||||
struct {
|
||||
u8 mode;
|
||||
u8 reserved1;
|
||||
u8 speed;
|
||||
u8 reserved2 : 1;
|
||||
u8 disableDirtyWake : 1;
|
||||
u8 reserved3 : 2;
|
||||
u8 downshift : 4;
|
||||
};
|
||||
uint32_t val;
|
||||
struct {
|
||||
uint8_t mode;
|
||||
uint8_t reserved1;
|
||||
uint8_t speed;
|
||||
uint8_t reserved2 : 1;
|
||||
uint8_t disableDirtyWake : 1;
|
||||
uint8_t reserved3 : 2;
|
||||
uint8_t downshift : 4;
|
||||
};
|
||||
} fw1x_state_reg;
|
||||
|
||||
int fw1x_reset(struct aq_hw* hw);
|
||||
|
||||
int fw1x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode, aq_fw_link_speed_t speed);
|
||||
int fw1x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode, aq_fw_link_speed_t* speed, aq_fw_link_fc_t* fc);
|
||||
int fw1x_get_mac_addr(struct aq_hw* hw, u8* mac_addr);
|
||||
int fw1x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode,
|
||||
aq_fw_link_speed_t speed);
|
||||
int fw1x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode,
|
||||
aq_fw_link_speed_t* speed, aq_fw_link_fc_t* fc);
|
||||
int fw1x_get_mac_addr(struct aq_hw* hw, uint8_t* mac_addr);
|
||||
int fw1x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats);
|
||||
|
||||
|
||||
static
|
||||
fw1x_mode mpi_mode_to_fw1x_(enum aq_hw_fw_mpi_state_e mode)
|
||||
static fw1x_mode
|
||||
mpi_mode_to_fw1x_(enum aq_hw_fw_mpi_state_e mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case MPI_DEINIT:
|
||||
return (FW1X_MPI_DEINIT);
|
||||
switch (mode) {
|
||||
case MPI_DEINIT:
|
||||
return (FW1X_MPI_DEINIT);
|
||||
|
||||
case MPI_INIT:
|
||||
return (FW1X_MPI_INIT);
|
||||
case MPI_INIT:
|
||||
return (FW1X_MPI_INIT);
|
||||
|
||||
case MPI_POWER:
|
||||
return (FW1X_MPI_POWER);
|
||||
case MPI_POWER:
|
||||
return (FW1X_MPI_POWER);
|
||||
|
||||
case MPI_RESET:
|
||||
return (FW1X_MPI_RESERVED);
|
||||
}
|
||||
case MPI_RESET:
|
||||
return (FW1X_MPI_RESERVED);
|
||||
}
|
||||
|
||||
/*
|
||||
* We shouldn't get here.
|
||||
*/
|
||||
/*
|
||||
* We shouldn't get here.
|
||||
*/
|
||||
|
||||
return (FW1X_MPI_RESERVED);
|
||||
return (FW1X_MPI_RESERVED);
|
||||
}
|
||||
|
||||
static
|
||||
aq_fw1x_rate link_speed_mask_to_fw1x_(u32 /*aq_fw_link_speed*/ speed)
|
||||
static aq_fw1x_rate
|
||||
link_speed_mask_to_fw1x_(uint32_t /*aq_fw_link_speed*/ speed)
|
||||
{
|
||||
u32 rate = 0;
|
||||
if (speed & aq_fw_10G)
|
||||
rate |= FW1X_RATE_10G;
|
||||
uint32_t rate = 0;
|
||||
if (speed & aq_fw_10G)
|
||||
rate |= FW1X_RATE_10G;
|
||||
|
||||
if (speed & aq_fw_5G) {
|
||||
rate |= FW1X_RATE_5G;
|
||||
rate |= FW1X_RATE_5GSR;
|
||||
}
|
||||
if (speed & aq_fw_5G) {
|
||||
rate |= FW1X_RATE_5G;
|
||||
rate |= FW1X_RATE_5GSR;
|
||||
}
|
||||
|
||||
if (speed & aq_fw_2G5)
|
||||
rate |= FW1X_RATE_2G5;
|
||||
if (speed & aq_fw_2G5)
|
||||
rate |= FW1X_RATE_2G5;
|
||||
|
||||
if (speed & aq_fw_1G)
|
||||
rate |= FW1X_RATE_1G;
|
||||
if (speed & aq_fw_1G)
|
||||
rate |= FW1X_RATE_1G;
|
||||
|
||||
if (speed & aq_fw_100M)
|
||||
rate |= FW1X_RATE_100M;
|
||||
if (speed & aq_fw_100M)
|
||||
rate |= FW1X_RATE_100M;
|
||||
|
||||
return ((aq_fw1x_rate)rate);
|
||||
return ((aq_fw1x_rate)rate);
|
||||
}
|
||||
|
||||
static
|
||||
aq_fw_link_speed_t fw1x_rate_to_link_speed_(aq_fw1x_rate rate)
|
||||
static aq_fw_link_speed_t
|
||||
fw1x_rate_to_link_speed_(aq_fw1x_rate rate)
|
||||
{
|
||||
switch (rate) {
|
||||
case FW1X_RATE_10G:
|
||||
return (aq_fw_10G);
|
||||
case FW1X_RATE_5G:
|
||||
case FW1X_RATE_5GSR:
|
||||
return (aq_fw_5G);
|
||||
case FW1X_RATE_2G5:
|
||||
return (aq_fw_2G5);
|
||||
case FW1X_RATE_1G:
|
||||
return (aq_fw_1G);
|
||||
case FW1X_RATE_100M:
|
||||
return (aq_fw_100M);
|
||||
case FW1X_RATE_INVALID:
|
||||
return (aq_fw_none);
|
||||
}
|
||||
switch (rate) {
|
||||
case FW1X_RATE_10G:
|
||||
return (aq_fw_10G);
|
||||
case FW1X_RATE_5G:
|
||||
case FW1X_RATE_5GSR:
|
||||
return (aq_fw_5G);
|
||||
case FW1X_RATE_2G5:
|
||||
return (aq_fw_2G5);
|
||||
case FW1X_RATE_1G:
|
||||
return (aq_fw_1G);
|
||||
case FW1X_RATE_100M:
|
||||
return (aq_fw_100M);
|
||||
case FW1X_RATE_INVALID:
|
||||
return (aq_fw_none);
|
||||
}
|
||||
|
||||
/*
|
||||
* We should never get here.
|
||||
*/
|
||||
/*
|
||||
* We should never get here.
|
||||
*/
|
||||
|
||||
return (aq_fw_none);
|
||||
return (aq_fw_none);
|
||||
}
|
||||
|
||||
int fw1x_reset(struct aq_hw* hal)
|
||||
int
|
||||
fw1x_reset(struct aq_hw* hal)
|
||||
{
|
||||
u32 tid0 = ~0u; /*< Initial value of MBOX transactionId. */
|
||||
struct aq_hw_fw_mbox mbox;
|
||||
const int retryCount = 1000;
|
||||
uint32_t tid0 = ~0u; /*< Initial value of MBOX transactionId. */
|
||||
struct aq_hw_fw_mbox mbox;
|
||||
const int retryCount = 1000;
|
||||
|
||||
for (int i = 0; i < retryCount; ++i) {
|
||||
// Read the beginning of Statistics structure to capture the Transaction ID.
|
||||
aq_hw_fw_downld_dwords(hal, hal->mbox_addr, (u32*)&mbox,
|
||||
(u32)((char*)&mbox.stats - (char*)&mbox) / sizeof(u32));
|
||||
for (int i = 0; i < retryCount; ++i) {
|
||||
// Read the beginning of Statistics structure to capture the Transaction ID.
|
||||
aq_hw_fw_downld_dwords(hal, hal->mbox_addr, (uint32_t*)&mbox,
|
||||
(uint32_t)((char*)&mbox.stats - (char*)&mbox) / sizeof(uint32_t));
|
||||
|
||||
// Successfully read the stats.
|
||||
if (tid0 == ~0U) {
|
||||
// We have read the initial value.
|
||||
tid0 = mbox.transaction_id;
|
||||
continue;
|
||||
} else if (mbox.transaction_id != tid0) {
|
||||
/*
|
||||
* Compare transaction ID to initial value.
|
||||
* If it's different means f/w is alive. We're done.
|
||||
*/
|
||||
// Successfully read the stats.
|
||||
if (tid0 == ~0U) {
|
||||
// We have read the initial value.
|
||||
tid0 = mbox.transaction_id;
|
||||
continue;
|
||||
} else if (mbox.transaction_id != tid0) {
|
||||
/*
|
||||
* Compare transaction ID to initial value.
|
||||
* If it's different means f/w is alive. We're done.
|
||||
*/
|
||||
|
||||
return (EOK);
|
||||
}
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Transaction ID value haven't changed since last time.
|
||||
* Try reading the stats again.
|
||||
*/
|
||||
usec_delay(10);
|
||||
}
|
||||
/*
|
||||
* Transaction ID value haven't changed since last time.
|
||||
* Try reading the stats again.
|
||||
*/
|
||||
usec_delay(10);
|
||||
}
|
||||
|
||||
trace_error(dbg_init, "F/W 1.x reset finalize timeout");
|
||||
return (-EBUSY);
|
||||
trace_error(dbg_init, "F/W 1.x reset finalize timeout");
|
||||
return (-EBUSY);
|
||||
}
|
||||
|
||||
int fw1x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode, aq_fw_link_speed_t speed)
|
||||
int
|
||||
fw1x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode,
|
||||
aq_fw_link_speed_t speed)
|
||||
{
|
||||
union fw1x_state_reg state = {0};
|
||||
state.mode = mpi_mode_to_fw1x_(mode);
|
||||
state.speed = link_speed_mask_to_fw1x_(speed);
|
||||
union fw1x_state_reg state = {0};
|
||||
state.mode = mpi_mode_to_fw1x_(mode);
|
||||
state.speed = link_speed_mask_to_fw1x_(speed);
|
||||
|
||||
trace(dbg_init, "fw1x> set mode %d, rate mask = %#x; raw = %#x", state.mode, state.speed, state.val);
|
||||
trace(dbg_init, "fw1x> set mode %d, rate mask = %#x; raw = %#x",
|
||||
state.mode, state.speed, state.val);
|
||||
|
||||
AQ_WRITE_REG(hw, FW1X_MPI_CONTROL_ADR, state.val);
|
||||
AQ_WRITE_REG(hw, FW1X_MPI_CONTROL_ADR, state.val);
|
||||
|
||||
return (EOK);
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
int fw1x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode, aq_fw_link_speed_t* speed, aq_fw_link_fc_t* fc)
|
||||
int
|
||||
fw1x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode,
|
||||
aq_fw_link_speed_t* speed, aq_fw_link_fc_t* fc)
|
||||
{
|
||||
union fw1x_state_reg state = { .val = AQ_READ_REG(hw, AQ_HW_MPI_STATE_ADR) };
|
||||
union fw1x_state_reg state = { .val = AQ_READ_REG(hw, AQ_HW_MPI_STATE_ADR) };
|
||||
|
||||
trace(dbg_init, "fw1x> get_mode(): 0x36c -> %x, 0x368 -> %x", state.val, AQ_READ_REG(hw, AQ_HW_MPI_CONTROL_ADR));
|
||||
trace(dbg_init, "fw1x> get_mode(): 0x36c -> %x, 0x368 -> %x",
|
||||
state.val, AQ_READ_REG(hw, AQ_HW_MPI_CONTROL_ADR));
|
||||
|
||||
enum aq_hw_fw_mpi_state_e md = MPI_DEINIT;
|
||||
enum aq_hw_fw_mpi_state_e md = MPI_DEINIT;
|
||||
|
||||
switch (state.mode) {
|
||||
case FW1X_MPI_DEINIT:
|
||||
md = MPI_DEINIT;
|
||||
break;
|
||||
case FW1X_MPI_RESERVED:
|
||||
md = MPI_RESET;
|
||||
break;
|
||||
case FW1X_MPI_INIT:
|
||||
md = MPI_INIT;
|
||||
break;
|
||||
case FW1X_MPI_POWER:
|
||||
md = MPI_POWER;
|
||||
break;
|
||||
}
|
||||
switch (state.mode) {
|
||||
case FW1X_MPI_DEINIT:
|
||||
md = MPI_DEINIT;
|
||||
break;
|
||||
case FW1X_MPI_RESERVED:
|
||||
md = MPI_RESET;
|
||||
break;
|
||||
case FW1X_MPI_INIT:
|
||||
md = MPI_INIT;
|
||||
break;
|
||||
case FW1X_MPI_POWER:
|
||||
md = MPI_POWER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (mode)
|
||||
*mode = md;
|
||||
if (mode)
|
||||
*mode = md;
|
||||
|
||||
if (speed)
|
||||
*speed = fw1x_rate_to_link_speed_(state.speed);
|
||||
if (speed)
|
||||
*speed = fw1x_rate_to_link_speed_(state.speed);
|
||||
|
||||
*fc = aq_fw_fc_none;
|
||||
*fc = aq_fw_fc_none;
|
||||
|
||||
AQ_DBG_EXIT(EOK);
|
||||
return (EOK);
|
||||
AQ_DBG_EXIT(EOK);
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
|
||||
int fw1x_get_mac_addr(struct aq_hw* hw, u8* mac)
|
||||
int
|
||||
fw1x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
|
||||
{
|
||||
int err = -EFAULT;
|
||||
u32 mac_addr[2];
|
||||
int err = -EFAULT;
|
||||
uint32_t mac_addr[2];
|
||||
|
||||
AQ_DBG_ENTER();
|
||||
AQ_DBG_ENTER();
|
||||
|
||||
u32 efuse_shadow_addr = AQ_READ_REG(hw, 0x374);
|
||||
if (efuse_shadow_addr == 0) {
|
||||
trace_error(dbg_init, "couldn't read eFUSE Shadow Address");
|
||||
AQ_DBG_EXIT(-EFAULT);
|
||||
return (-EFAULT);
|
||||
}
|
||||
uint32_t efuse_shadow_addr = AQ_READ_REG(hw, 0x374);
|
||||
if (efuse_shadow_addr == 0) {
|
||||
trace_error(dbg_init, "couldn't read eFUSE Shadow Address");
|
||||
AQ_DBG_EXIT(-EFAULT);
|
||||
return (-EFAULT);
|
||||
}
|
||||
|
||||
err = aq_hw_fw_downld_dwords(hw, efuse_shadow_addr + (40 * 4),
|
||||
mac_addr, ARRAY_SIZE(mac_addr));
|
||||
if (err < 0) {
|
||||
mac_addr[0] = 0;
|
||||
mac_addr[1] = 0;
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
err = aq_hw_fw_downld_dwords(hw, efuse_shadow_addr + (40 * 4),
|
||||
mac_addr, ARRAY_SIZE(mac_addr));
|
||||
if (err < 0) {
|
||||
mac_addr[0] = 0;
|
||||
mac_addr[1] = 0;
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
mac_addr[0] = bswap32(mac_addr[0]);
|
||||
mac_addr[1] = bswap32(mac_addr[1]);
|
||||
mac_addr[0] = bswap32(mac_addr[0]);
|
||||
mac_addr[1] = bswap32(mac_addr[1]);
|
||||
|
||||
memcpy(mac, (u8*)mac_addr, ETHER_ADDR_LEN);
|
||||
memcpy(mac, (uint8_t*)mac_addr, ETHER_ADDR_LEN);
|
||||
|
||||
trace(dbg_init, "fw1x> eFUSE MAC addr -> %02x-%02x-%02x-%02x-%02x-%02x",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
trace(dbg_init, "fw1x> eFUSE MAC addr -> %02x-%02x-%02x-%02x-%02x-%02x",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
AQ_DBG_EXIT(EOK);
|
||||
return (EOK);
|
||||
AQ_DBG_EXIT(EOK);
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
int fw1x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
|
||||
int
|
||||
fw1x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
|
||||
{
|
||||
int err = 0;
|
||||
int err = 0;
|
||||
|
||||
AQ_DBG_ENTER();
|
||||
err = aq_hw_fw_downld_dwords(hw, hw->mbox_addr, (u32*)(void*)&hw->mbox,
|
||||
sizeof hw->mbox / sizeof(u32));
|
||||
AQ_DBG_ENTER();
|
||||
err = aq_hw_fw_downld_dwords(hw, hw->mbox_addr,
|
||||
(uint32_t*)(void*)&hw->mbox, sizeof hw->mbox / sizeof(uint32_t));
|
||||
|
||||
if (err >= 0) {
|
||||
if (stats != &hw->mbox.stats)
|
||||
memcpy(stats, &hw->mbox.stats, sizeof *stats);
|
||||
if (err >= 0) {
|
||||
if (stats != &hw->mbox.stats)
|
||||
memcpy(stats, &hw->mbox.stats, sizeof *stats);
|
||||
|
||||
stats->dpc = reg_rx_dma_stat_counter7get(hw);
|
||||
}
|
||||
stats->dpc = reg_rx_dma_stat_counter7get(hw);
|
||||
}
|
||||
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
struct aq_firmware_ops aq_fw1x_ops =
|
||||
{
|
||||
.reset = fw1x_reset,
|
||||
.reset = fw1x_reset,
|
||||
|
||||
.set_mode = fw1x_set_mode,
|
||||
.get_mode = fw1x_get_mode,
|
||||
.set_mode = fw1x_set_mode,
|
||||
.get_mode = fw1x_get_mode,
|
||||
|
||||
.get_mac_addr = fw1x_get_mac_addr,
|
||||
.get_stats = fw1x_get_stats,
|
||||
.get_mac_addr = fw1x_get_mac_addr,
|
||||
.get_stats = fw1x_get_stats,
|
||||
};
|
||||
|
||||
|
||||
+299
-271
@@ -52,112 +52,112 @@ __FBSDID("$FreeBSD$");
|
||||
#include "aq_dbg.h"
|
||||
|
||||
typedef enum {
|
||||
CAPS_LO_10BASET_HD = 0x00,
|
||||
CAPS_LO_10BASET_FD,
|
||||
CAPS_LO_100BASETX_HD,
|
||||
CAPS_LO_100BASET4_HD,
|
||||
CAPS_LO_100BASET2_HD,
|
||||
CAPS_LO_100BASETX_FD,
|
||||
CAPS_LO_100BASET2_FD,
|
||||
CAPS_LO_1000BASET_HD,
|
||||
CAPS_LO_1000BASET_FD,
|
||||
CAPS_LO_2P5GBASET_FD,
|
||||
CAPS_LO_5GBASET_FD,
|
||||
CAPS_LO_10GBASET_FD,
|
||||
CAPS_LO_10BASET_HD = 0x00,
|
||||
CAPS_LO_10BASET_FD,
|
||||
CAPS_LO_100BASETX_HD,
|
||||
CAPS_LO_100BASET4_HD,
|
||||
CAPS_LO_100BASET2_HD,
|
||||
CAPS_LO_100BASETX_FD,
|
||||
CAPS_LO_100BASET2_FD,
|
||||
CAPS_LO_1000BASET_HD,
|
||||
CAPS_LO_1000BASET_FD,
|
||||
CAPS_LO_2P5GBASET_FD,
|
||||
CAPS_LO_5GBASET_FD,
|
||||
CAPS_LO_10GBASET_FD,
|
||||
} fw2x_caps_lo;
|
||||
|
||||
typedef enum {
|
||||
CAPS_HI_RESERVED1 = 0x00,
|
||||
CAPS_HI_10BASET_EEE,
|
||||
CAPS_HI_RESERVED2,
|
||||
CAPS_HI_PAUSE,
|
||||
CAPS_HI_ASYMMETRIC_PAUSE,
|
||||
CAPS_HI_100BASETX_EEE,
|
||||
CAPS_HI_RESERVED3,
|
||||
CAPS_HI_RESERVED4,
|
||||
CAPS_HI_1000BASET_FD_EEE,
|
||||
CAPS_HI_2P5GBASET_FD_EEE,
|
||||
CAPS_HI_5GBASET_FD_EEE,
|
||||
CAPS_HI_10GBASET_FD_EEE,
|
||||
CAPS_HI_RESERVED5,
|
||||
CAPS_HI_RESERVED6,
|
||||
CAPS_HI_RESERVED7,
|
||||
CAPS_HI_RESERVED8,
|
||||
CAPS_HI_RESERVED9,
|
||||
CAPS_HI_CABLE_DIAG,
|
||||
CAPS_HI_TEMPERATURE,
|
||||
CAPS_HI_DOWNSHIFT,
|
||||
CAPS_HI_PTP_AVB_EN,
|
||||
CAPS_HI_MEDIA_DETECT,
|
||||
CAPS_HI_LINK_DROP,
|
||||
CAPS_HI_SLEEP_PROXY,
|
||||
CAPS_HI_WOL,
|
||||
CAPS_HI_MAC_STOP,
|
||||
CAPS_HI_EXT_LOOPBACK,
|
||||
CAPS_HI_INT_LOOPBACK,
|
||||
CAPS_HI_EFUSE_AGENT,
|
||||
CAPS_HI_WOL_TIMER,
|
||||
CAPS_HI_STATISTICS,
|
||||
CAPS_HI_TRANSACTION_ID,
|
||||
CAPS_HI_RESERVED1 = 0x00,
|
||||
CAPS_HI_10BASET_EEE,
|
||||
CAPS_HI_RESERVED2,
|
||||
CAPS_HI_PAUSE,
|
||||
CAPS_HI_ASYMMETRIC_PAUSE,
|
||||
CAPS_HI_100BASETX_EEE,
|
||||
CAPS_HI_RESERVED3,
|
||||
CAPS_HI_RESERVED4,
|
||||
CAPS_HI_1000BASET_FD_EEE,
|
||||
CAPS_HI_2P5GBASET_FD_EEE,
|
||||
CAPS_HI_5GBASET_FD_EEE,
|
||||
CAPS_HI_10GBASET_FD_EEE,
|
||||
CAPS_HI_RESERVED5,
|
||||
CAPS_HI_RESERVED6,
|
||||
CAPS_HI_RESERVED7,
|
||||
CAPS_HI_RESERVED8,
|
||||
CAPS_HI_RESERVED9,
|
||||
CAPS_HI_CABLE_DIAG,
|
||||
CAPS_HI_TEMPERATURE,
|
||||
CAPS_HI_DOWNSHIFT,
|
||||
CAPS_HI_PTP_AVB_EN,
|
||||
CAPS_HI_MEDIA_DETECT,
|
||||
CAPS_HI_LINK_DROP,
|
||||
CAPS_HI_SLEEP_PROXY,
|
||||
CAPS_HI_WOL,
|
||||
CAPS_HI_MAC_STOP,
|
||||
CAPS_HI_EXT_LOOPBACK,
|
||||
CAPS_HI_INT_LOOPBACK,
|
||||
CAPS_HI_EFUSE_AGENT,
|
||||
CAPS_HI_WOL_TIMER,
|
||||
CAPS_HI_STATISTICS,
|
||||
CAPS_HI_TRANSACTION_ID,
|
||||
} fw2x_caps_hi;
|
||||
|
||||
typedef enum aq_fw2x_rate
|
||||
{
|
||||
FW2X_RATE_100M = 0x20,
|
||||
FW2X_RATE_1G = 0x100,
|
||||
FW2X_RATE_2G5 = 0x200,
|
||||
FW2X_RATE_5G = 0x400,
|
||||
FW2X_RATE_10G = 0x800,
|
||||
FW2X_RATE_100M = 0x20,
|
||||
FW2X_RATE_1G = 0x100,
|
||||
FW2X_RATE_2G5 = 0x200,
|
||||
FW2X_RATE_5G = 0x400,
|
||||
FW2X_RATE_10G = 0x800,
|
||||
} aq_fw2x_rate;
|
||||
|
||||
|
||||
typedef struct fw2x_msm_statistics
|
||||
{
|
||||
uint32_t uprc;
|
||||
uint32_t mprc;
|
||||
uint32_t bprc;
|
||||
uint32_t erpt;
|
||||
uint32_t uptc;
|
||||
uint32_t mptc;
|
||||
uint32_t bptc;
|
||||
uint32_t erpr;
|
||||
uint32_t mbtc;
|
||||
uint32_t bbtc;
|
||||
uint32_t mbrc;
|
||||
uint32_t bbrc;
|
||||
uint32_t ubrc;
|
||||
uint32_t ubtc;
|
||||
uint32_t ptc;
|
||||
uint32_t prc;
|
||||
uint32_t uprc;
|
||||
uint32_t mprc;
|
||||
uint32_t bprc;
|
||||
uint32_t erpt;
|
||||
uint32_t uptc;
|
||||
uint32_t mptc;
|
||||
uint32_t bptc;
|
||||
uint32_t erpr;
|
||||
uint32_t mbtc;
|
||||
uint32_t bbtc;
|
||||
uint32_t mbrc;
|
||||
uint32_t bbrc;
|
||||
uint32_t ubrc;
|
||||
uint32_t ubtc;
|
||||
uint32_t ptc;
|
||||
uint32_t prc;
|
||||
} fw2x_msm_statistics;
|
||||
|
||||
typedef struct fw2x_phy_cable_diag_data
|
||||
{
|
||||
u32 lane_data[4];
|
||||
uint32_t lane_data[4];
|
||||
} fw2x_phy_cable_diag_data;
|
||||
|
||||
typedef struct fw2x_capabilities {
|
||||
u32 caps_lo;
|
||||
u32 caps_hi;
|
||||
uint32_t caps_lo;
|
||||
uint32_t caps_hi;
|
||||
} fw2x_capabilities;
|
||||
|
||||
typedef struct fw2x_mailbox // struct fwHostInterface
|
||||
{
|
||||
u32 version;
|
||||
u32 transaction_id;
|
||||
s32 error;
|
||||
fw2x_msm_statistics msm; // msmStatistics_t msm;
|
||||
u16 phy_h_bit;
|
||||
u16 phy_fault_code;
|
||||
s16 phy_temperature;
|
||||
u8 cable_len;
|
||||
u8 reserved1;
|
||||
fw2x_phy_cable_diag_data diag_data;
|
||||
u32 reserved[8];
|
||||
uint32_t version;
|
||||
uint32_t transaction_id;
|
||||
int32_t error;
|
||||
fw2x_msm_statistics msm; // msmStatistics_t msm;
|
||||
uint16_t phy_h_bit;
|
||||
uint16_t phy_fault_code;
|
||||
int16_t phy_temperature;
|
||||
uint8_t cable_len;
|
||||
uint8_t reserved1;
|
||||
fw2x_phy_cable_diag_data diag_data;
|
||||
uint32_t reserved[8];
|
||||
|
||||
fw2x_capabilities caps;
|
||||
fw2x_capabilities caps;
|
||||
|
||||
/* ... */
|
||||
/* ... */
|
||||
} fw2x_mailbox;
|
||||
|
||||
|
||||
@@ -196,303 +196,331 @@ typedef struct fw2x_mailbox // struct fwHostInterface
|
||||
//@{
|
||||
int fw2x_reset(struct aq_hw* hw);
|
||||
|
||||
int fw2x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode, aq_fw_link_speed_t speed);
|
||||
int fw2x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode, aq_fw_link_speed_t* speed, aq_fw_link_fc_t* fc);
|
||||
int fw2x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode,
|
||||
aq_fw_link_speed_t speed);
|
||||
int fw2x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode,
|
||||
aq_fw_link_speed_t* speed, aq_fw_link_fc_t* fc);
|
||||
|
||||
int fw2x_get_mac_addr(struct aq_hw* hw, u8* mac);
|
||||
int fw2x_get_mac_addr(struct aq_hw* hw, uint8_t* mac);
|
||||
int fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats);
|
||||
//@}
|
||||
|
||||
|
||||
|
||||
static u64 read64_(struct aq_hw* hw, u32 addr)
|
||||
static uint64_t
|
||||
read64_(struct aq_hw* hw, uint32_t addr)
|
||||
{
|
||||
u64 lo = AQ_READ_REG(hw, addr);
|
||||
u64 hi = AQ_READ_REG(hw, addr + 4);
|
||||
return (lo | (hi << 32));
|
||||
uint64_t lo = AQ_READ_REG(hw, addr);
|
||||
uint64_t hi = AQ_READ_REG(hw, addr + 4);
|
||||
return (lo | (hi << 32));
|
||||
}
|
||||
|
||||
static uint64_t get_mpi_ctrl_(struct aq_hw* hw)
|
||||
static uint64_t
|
||||
get_mpi_ctrl_(struct aq_hw* hw)
|
||||
{
|
||||
return read64_(hw, FW2X_MPI_CONTROL_ADDR);
|
||||
return read64_(hw, FW2X_MPI_CONTROL_ADDR);
|
||||
}
|
||||
|
||||
static uint64_t get_mpi_state_(struct aq_hw* hw)
|
||||
static uint64_t
|
||||
get_mpi_state_(struct aq_hw* hw)
|
||||
{
|
||||
return read64_(hw, FW2X_MPI_STATE_ADDR);
|
||||
return read64_(hw, FW2X_MPI_STATE_ADDR);
|
||||
}
|
||||
|
||||
static void set_mpi_ctrl_(struct aq_hw* hw, u64 value)
|
||||
static void
|
||||
set_mpi_ctrl_(struct aq_hw* hw, uint64_t value)
|
||||
{
|
||||
AQ_WRITE_REG(hw, FW2X_MPI_CONTROL_ADDR, (u32)value);
|
||||
AQ_WRITE_REG(hw, FW2X_MPI_CONTROL_ADDR + 4, (u32)(value >> 32));
|
||||
AQ_WRITE_REG(hw, FW2X_MPI_CONTROL_ADDR, (uint32_t)value);
|
||||
AQ_WRITE_REG(hw, FW2X_MPI_CONTROL_ADDR + 4, (uint32_t)(value >> 32));
|
||||
}
|
||||
|
||||
|
||||
int fw2x_reset(struct aq_hw* hw)
|
||||
int
|
||||
fw2x_reset(struct aq_hw* hw)
|
||||
{
|
||||
fw2x_capabilities caps = {0};
|
||||
AQ_DBG_ENTER();
|
||||
int err = aq_hw_fw_downld_dwords(hw, hw->mbox_addr + offsetof(fw2x_mailbox, caps), (u32*)&caps, sizeof caps/sizeof(u32));
|
||||
if (err == EOK) {
|
||||
hw->fw_caps = caps.caps_lo | ((u64)caps.caps_hi << 32);
|
||||
trace(dbg_init, "fw2x> F/W capabilities mask = %llx", (unsigned long long)hw->fw_caps);
|
||||
} else {
|
||||
trace_error(dbg_init, "fw2x> can't get F/W capabilities mask, error %d", err);
|
||||
}
|
||||
fw2x_capabilities caps = {0};
|
||||
AQ_DBG_ENTER();
|
||||
int err = aq_hw_fw_downld_dwords(hw,
|
||||
hw->mbox_addr + offsetof(fw2x_mailbox, caps),
|
||||
(uint32_t*)&caps, sizeof caps/sizeof(uint32_t));
|
||||
if (err == EOK) {
|
||||
hw->fw_caps = caps.caps_lo | ((uint64_t)caps.caps_hi << 32);
|
||||
trace(dbg_init,
|
||||
"fw2x> F/W capabilities mask = %llx",
|
||||
(unsigned long long)hw->fw_caps);
|
||||
} else {
|
||||
trace_error(dbg_init,
|
||||
"fw2x> can't get F/W capabilities mask, error %d", err);
|
||||
}
|
||||
|
||||
AQ_DBG_EXIT(EOK);
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
aq_fw2x_rate link_speed_mask_to_fw2x_(u32 speed)
|
||||
static aq_fw2x_rate
|
||||
link_speed_mask_to_fw2x_(uint32_t speed)
|
||||
{
|
||||
u32 rate = 0;
|
||||
uint32_t rate = 0;
|
||||
|
||||
AQ_DBG_ENTER();
|
||||
if (speed & aq_fw_10G)
|
||||
rate |= FW2X_RATE_10G;
|
||||
AQ_DBG_ENTER();
|
||||
if (speed & aq_fw_10G)
|
||||
rate |= FW2X_RATE_10G;
|
||||
|
||||
if (speed & aq_fw_5G)
|
||||
rate |= FW2X_RATE_5G;
|
||||
if (speed & aq_fw_5G)
|
||||
rate |= FW2X_RATE_5G;
|
||||
|
||||
if (speed & aq_fw_2G5)
|
||||
rate |= FW2X_RATE_2G5;
|
||||
if (speed & aq_fw_2G5)
|
||||
rate |= FW2X_RATE_2G5;
|
||||
|
||||
if (speed & aq_fw_1G)
|
||||
rate |= FW2X_RATE_1G;
|
||||
if (speed & aq_fw_1G)
|
||||
rate |= FW2X_RATE_1G;
|
||||
|
||||
if (speed & aq_fw_100M)
|
||||
rate |= FW2X_RATE_100M;
|
||||
if (speed & aq_fw_100M)
|
||||
rate |= FW2X_RATE_100M;
|
||||
|
||||
AQ_DBG_EXIT(rate);
|
||||
return ((aq_fw2x_rate)rate);
|
||||
AQ_DBG_EXIT(rate);
|
||||
return ((aq_fw2x_rate)rate);
|
||||
}
|
||||
|
||||
|
||||
int fw2x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode, aq_fw_link_speed_t speed)
|
||||
int
|
||||
fw2x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode,
|
||||
aq_fw_link_speed_t speed)
|
||||
{
|
||||
u64 mpi_ctrl = get_mpi_ctrl_(hw);
|
||||
|
||||
AQ_DBG_ENTERA("speed=%d", speed);
|
||||
switch (mode) {
|
||||
case MPI_INIT:
|
||||
mpi_ctrl &= ~FW2X_RATE_MASK;
|
||||
mpi_ctrl |= link_speed_mask_to_fw2x_(speed);
|
||||
mpi_ctrl &= ~FW2X_CAP_LINK_DROP;
|
||||
uint64_t mpi_ctrl = get_mpi_ctrl_(hw);
|
||||
|
||||
AQ_DBG_ENTERA("speed=%d", speed);
|
||||
switch (mode) {
|
||||
case MPI_INIT:
|
||||
mpi_ctrl &= ~FW2X_RATE_MASK;
|
||||
mpi_ctrl |= link_speed_mask_to_fw2x_(speed);
|
||||
mpi_ctrl &= ~FW2X_CAP_LINK_DROP;
|
||||
#if 0 // #todo #flowcontrol #pause #eee
|
||||
if (pHal->pCfg->eee)
|
||||
mpi_ctrl |= FW2X_EEE_MASK;
|
||||
if (pHal->pCfg->eee)
|
||||
mpi_ctrl |= FW2X_EEE_MASK;
|
||||
#endif
|
||||
if (hw->fc.fc_rx)
|
||||
mpi_ctrl |= FW2X_FW_CAP_PAUSE;
|
||||
if (hw->fc.fc_tx)
|
||||
mpi_ctrl |= FW2X_FW_CAP_ASYM_PAUSE;
|
||||
break;
|
||||
if (hw->fc.fc_rx)
|
||||
mpi_ctrl |= FW2X_FW_CAP_PAUSE;
|
||||
if (hw->fc.fc_tx)
|
||||
mpi_ctrl |= FW2X_FW_CAP_ASYM_PAUSE;
|
||||
break;
|
||||
|
||||
case MPI_DEINIT:
|
||||
mpi_ctrl &= ~(FW2X_RATE_MASK | FW2X_EEE_MASK);
|
||||
mpi_ctrl &= ~(FW2X_FW_CAP_PAUSE | FW2X_FW_CAP_ASYM_PAUSE);
|
||||
break;
|
||||
case MPI_DEINIT:
|
||||
mpi_ctrl &= ~(FW2X_RATE_MASK | FW2X_EEE_MASK);
|
||||
mpi_ctrl &= ~(FW2X_FW_CAP_PAUSE | FW2X_FW_CAP_ASYM_PAUSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
trace_error(dbg_init, "fw2x> unknown MPI state %d", mode);
|
||||
return (-EINVAL);
|
||||
}
|
||||
default:
|
||||
trace_error(dbg_init, "fw2x> unknown MPI state %d", mode);
|
||||
return (-EINVAL);
|
||||
}
|
||||
|
||||
set_mpi_ctrl_(hw, mpi_ctrl);
|
||||
AQ_DBG_EXIT(EOK);
|
||||
return (EOK);
|
||||
set_mpi_ctrl_(hw, mpi_ctrl);
|
||||
AQ_DBG_EXIT(EOK);
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
int fw2x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode, aq_fw_link_speed_t* link_speed, aq_fw_link_fc_t* fc)
|
||||
int
|
||||
fw2x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode,
|
||||
aq_fw_link_speed_t* link_speed, aq_fw_link_fc_t* fc)
|
||||
{
|
||||
u64 mpi_state = get_mpi_state_(hw);
|
||||
u32 rates = mpi_state & FW2X_RATE_MASK;
|
||||
uint64_t mpi_state = get_mpi_state_(hw);
|
||||
uint32_t rates = mpi_state & FW2X_RATE_MASK;
|
||||
|
||||
// AQ_DBG_ENTER();
|
||||
|
||||
if (mode) {
|
||||
u64 mpi_ctrl = get_mpi_ctrl_(hw);
|
||||
if (mpi_ctrl & FW2X_RATE_MASK)
|
||||
*mode = MPI_INIT;
|
||||
else
|
||||
*mode = MPI_DEINIT;
|
||||
}
|
||||
if (mode) {
|
||||
uint64_t mpi_ctrl = get_mpi_ctrl_(hw);
|
||||
if (mpi_ctrl & FW2X_RATE_MASK)
|
||||
*mode = MPI_INIT;
|
||||
else
|
||||
*mode = MPI_DEINIT;
|
||||
}
|
||||
|
||||
aq_fw_link_speed_t speed = aq_fw_none;
|
||||
|
||||
if (rates & FW2X_RATE_10G)
|
||||
speed = aq_fw_10G;
|
||||
else if (rates & FW2X_RATE_5G)
|
||||
speed = aq_fw_5G;
|
||||
else if (rates & FW2X_RATE_2G5)
|
||||
speed = aq_fw_2G5;
|
||||
else if (rates & FW2X_RATE_1G)
|
||||
speed = aq_fw_1G;
|
||||
else if (rates & FW2X_RATE_100M)
|
||||
speed = aq_fw_100M;
|
||||
aq_fw_link_speed_t speed = aq_fw_none;
|
||||
|
||||
if (link_speed)
|
||||
*link_speed = speed;
|
||||
if (rates & FW2X_RATE_10G)
|
||||
speed = aq_fw_10G;
|
||||
else if (rates & FW2X_RATE_5G)
|
||||
speed = aq_fw_5G;
|
||||
else if (rates & FW2X_RATE_2G5)
|
||||
speed = aq_fw_2G5;
|
||||
else if (rates & FW2X_RATE_1G)
|
||||
speed = aq_fw_1G;
|
||||
else if (rates & FW2X_RATE_100M)
|
||||
speed = aq_fw_100M;
|
||||
|
||||
*fc = (mpi_state & (FW2X_FW_CAP_PAUSE | FW2X_FW_CAP_ASYM_PAUSE)) >> (32 + CAPS_HI_PAUSE);
|
||||
if (link_speed)
|
||||
*link_speed = speed;
|
||||
|
||||
*fc = (mpi_state & (FW2X_FW_CAP_PAUSE | FW2X_FW_CAP_ASYM_PAUSE)) >>
|
||||
(32 + CAPS_HI_PAUSE);
|
||||
|
||||
// AQ_DBG_EXIT(0);
|
||||
return (EOK);
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
|
||||
int fw2x_get_mac_addr(struct aq_hw* hw, u8* mac)
|
||||
int
|
||||
fw2x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
|
||||
{
|
||||
int err = -EFAULT;
|
||||
u32 mac_addr[2];
|
||||
int err = -EFAULT;
|
||||
uint32_t mac_addr[2];
|
||||
|
||||
AQ_DBG_ENTER();
|
||||
AQ_DBG_ENTER();
|
||||
|
||||
u32 efuse_shadow_addr = AQ_READ_REG(hw, 0x364);
|
||||
if (efuse_shadow_addr == 0) {
|
||||
trace_error(dbg_init, "couldn't read eFUSE Shadow Address");
|
||||
AQ_DBG_EXIT(-EFAULT);
|
||||
return (-EFAULT);
|
||||
}
|
||||
uint32_t efuse_shadow_addr = AQ_READ_REG(hw, 0x364);
|
||||
if (efuse_shadow_addr == 0) {
|
||||
trace_error(dbg_init, "couldn't read eFUSE Shadow Address");
|
||||
AQ_DBG_EXIT(-EFAULT);
|
||||
return (-EFAULT);
|
||||
}
|
||||
|
||||
err = aq_hw_fw_downld_dwords(hw, efuse_shadow_addr + (40 * 4),
|
||||
mac_addr, ARRAY_SIZE(mac_addr));
|
||||
if (err < 0) {
|
||||
mac_addr[0] = 0;
|
||||
mac_addr[1] = 0;
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
err = aq_hw_fw_downld_dwords(hw, efuse_shadow_addr + (40 * 4), mac_addr,
|
||||
ARRAY_SIZE(mac_addr));
|
||||
if (err < 0) {
|
||||
mac_addr[0] = 0;
|
||||
mac_addr[1] = 0;
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
mac_addr[0] = bswap32(mac_addr[0]);
|
||||
mac_addr[1] = bswap32(mac_addr[1]);
|
||||
mac_addr[0] = bswap32(mac_addr[0]);
|
||||
mac_addr[1] = bswap32(mac_addr[1]);
|
||||
|
||||
memcpy(mac, (u8*)mac_addr, ETHER_ADDR_LEN);
|
||||
memcpy(mac, (uint8_t*)mac_addr, ETHER_ADDR_LEN);
|
||||
|
||||
AQ_DBG_EXIT(EOK);
|
||||
return (EOK);
|
||||
AQ_DBG_EXIT(EOK);
|
||||
return (EOK);
|
||||
}
|
||||
|
||||
static inline
|
||||
void fw2x_stats_to_fw_stats_(struct aq_hw_stats_s* dst, const fw2x_msm_statistics* src)
|
||||
static inline void
|
||||
fw2x_stats_to_fw_stats_(struct aq_hw_stats_s* dst,
|
||||
const fw2x_msm_statistics* src)
|
||||
{
|
||||
dst->uprc = src->uprc;
|
||||
dst->mprc = src->mprc;
|
||||
dst->bprc = src->bprc;
|
||||
dst->erpt = src->erpt;
|
||||
dst->uptc = src->uptc;
|
||||
dst->mptc = src->mptc;
|
||||
dst->bptc = src->bptc;
|
||||
dst->erpr = src->erpr;
|
||||
dst->mbtc = src->mbtc;
|
||||
dst->bbtc = src->bbtc;
|
||||
dst->mbrc = src->mbrc;
|
||||
dst->bbrc = src->bbrc;
|
||||
dst->ubrc = src->ubrc;
|
||||
dst->ubtc = src->ubtc;
|
||||
dst->ptc = src->ptc;
|
||||
dst->prc = src->prc;
|
||||
dst->uprc = src->uprc;
|
||||
dst->mprc = src->mprc;
|
||||
dst->bprc = src->bprc;
|
||||
dst->erpt = src->erpt;
|
||||
dst->uptc = src->uptc;
|
||||
dst->mptc = src->mptc;
|
||||
dst->bptc = src->bptc;
|
||||
dst->erpr = src->erpr;
|
||||
dst->mbtc = src->mbtc;
|
||||
dst->bbtc = src->bbtc;
|
||||
dst->mbrc = src->mbrc;
|
||||
dst->bbrc = src->bbrc;
|
||||
dst->ubrc = src->ubrc;
|
||||
dst->ubtc = src->ubtc;
|
||||
dst->ptc = src->ptc;
|
||||
dst->prc = src->prc;
|
||||
}
|
||||
|
||||
|
||||
static bool toggle_mpi_ctrl_and_wait_(struct aq_hw* hw, u64 mask, u32 timeout_ms, u32 try_count)
|
||||
static bool
|
||||
toggle_mpi_ctrl_and_wait_(struct aq_hw* hw, uint64_t mask, uint32_t timeout_ms,
|
||||
uint32_t try_count)
|
||||
{
|
||||
u64 ctrl = get_mpi_ctrl_(hw);
|
||||
u64 state = get_mpi_state_(hw);
|
||||
uint64_t ctrl = get_mpi_ctrl_(hw);
|
||||
uint64_t state = get_mpi_state_(hw);
|
||||
|
||||
// AQ_DBG_ENTER();
|
||||
// First, check that control and state values are consistent
|
||||
if ((ctrl & mask) != (state & mask)) {
|
||||
trace_warn(dbg_fw, "fw2x> MPI control (%#llx) and state (%#llx) are not consistent for mask %#llx!",
|
||||
(unsigned long long)ctrl, (unsigned long long)state, (unsigned long long)mask);
|
||||
// First, check that control and state values are consistent
|
||||
if ((ctrl & mask) != (state & mask)) {
|
||||
trace_warn(dbg_fw,
|
||||
"fw2x> MPI control (%#llx) and state (%#llx) are not consistent for mask %#llx!",
|
||||
(unsigned long long)ctrl, (unsigned long long)state,
|
||||
(unsigned long long)mask);
|
||||
AQ_DBG_EXIT(false);
|
||||
return (false);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
// Invert bits (toggle) in control register
|
||||
ctrl ^= mask;
|
||||
set_mpi_ctrl_(hw, ctrl);
|
||||
// Invert bits (toggle) in control register
|
||||
ctrl ^= mask;
|
||||
set_mpi_ctrl_(hw, ctrl);
|
||||
|
||||
// Clear all bits except masked
|
||||
ctrl &= mask;
|
||||
// Clear all bits except masked
|
||||
ctrl &= mask;
|
||||
|
||||
// Wait for FW reflecting change in state register
|
||||
while (try_count-- != 0) {
|
||||
if ((get_mpi_state_(hw) & mask) == ctrl)
|
||||
// Wait for FW reflecting change in state register
|
||||
while (try_count-- != 0) {
|
||||
if ((get_mpi_state_(hw) & mask) == ctrl)
|
||||
{
|
||||
// AQ_DBG_EXIT(true);
|
||||
return (true);
|
||||
return (true);
|
||||
}
|
||||
msec_delay(timeout_ms);
|
||||
}
|
||||
msec_delay(timeout_ms);
|
||||
}
|
||||
|
||||
trace_detail(dbg_fw, "f/w2x> timeout while waiting for response in state register for bit %#llx!", (unsigned long long)mask);
|
||||
trace_detail(dbg_fw,
|
||||
"f/w2x> timeout while waiting for response in state register for bit %#llx!",
|
||||
(unsigned long long)mask);
|
||||
// AQ_DBG_EXIT(false);
|
||||
return (false);
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
int fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
|
||||
int
|
||||
fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
|
||||
{
|
||||
int err = 0;
|
||||
fw2x_msm_statistics fw2x_stats = {0};
|
||||
int err = 0;
|
||||
fw2x_msm_statistics fw2x_stats = {0};
|
||||
|
||||
// AQ_DBG_ENTER();
|
||||
|
||||
if ((hw->fw_caps & FW2X_CAP_STATISTICS) == 0) {
|
||||
trace_warn(dbg_fw, "fw2x> statistics not supported by F/W");
|
||||
return (-ENOTSUP);
|
||||
}
|
||||
if ((hw->fw_caps & FW2X_CAP_STATISTICS) == 0) {
|
||||
trace_warn(dbg_fw, "fw2x> statistics not supported by F/W");
|
||||
return (-ENOTSUP);
|
||||
}
|
||||
|
||||
// Say to F/W to update the statistics
|
||||
if (!toggle_mpi_ctrl_and_wait_(hw, FW2X_CAP_STATISTICS, 1, 25)) {
|
||||
trace_error(dbg_fw, "fw2x> statistics update timeout");
|
||||
// Say to F/W to update the statistics
|
||||
if (!toggle_mpi_ctrl_and_wait_(hw, FW2X_CAP_STATISTICS, 1, 25)) {
|
||||
trace_error(dbg_fw, "fw2x> statistics update timeout");
|
||||
AQ_DBG_EXIT(-ETIME);
|
||||
return (-ETIME);
|
||||
}
|
||||
return (-ETIME);
|
||||
}
|
||||
|
||||
err = aq_hw_fw_downld_dwords(hw, hw->mbox_addr + offsetof(fw2x_mailbox, msm),
|
||||
(u32*)&fw2x_stats, sizeof fw2x_stats/sizeof(u32));
|
||||
err = aq_hw_fw_downld_dwords(hw,
|
||||
hw->mbox_addr + offsetof(fw2x_mailbox, msm),
|
||||
(uint32_t*)&fw2x_stats, sizeof fw2x_stats/sizeof(uint32_t));
|
||||
|
||||
fw2x_stats_to_fw_stats_(stats, &fw2x_stats);
|
||||
fw2x_stats_to_fw_stats_(stats, &fw2x_stats);
|
||||
|
||||
if (err != EOK)
|
||||
trace_error(dbg_fw, "fw2x> download statistics data FAILED, error %d", err);
|
||||
if (err != EOK)
|
||||
trace_error(dbg_fw,
|
||||
"fw2x> download statistics data FAILED, error %d", err);
|
||||
|
||||
// AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
static int fw2x_led_control(struct aq_hw* hw, u32 onoff)
|
||||
static int
|
||||
fw2x_led_control(struct aq_hw* hw, uint32_t onoff)
|
||||
{
|
||||
int err = 0;
|
||||
int err = 0;
|
||||
|
||||
AQ_DBG_ENTER();
|
||||
AQ_DBG_ENTER();
|
||||
|
||||
aq_hw_fw_version ver_expected = { .raw = FW2X_FW_MIN_VER_LED};
|
||||
if (aq_hw_ver_match(&ver_expected, &hw->fw_version))
|
||||
AQ_WRITE_REG(hw, FW2X_MPI_LED_ADDR, (onoff)?
|
||||
((FW2X_LED_BLINK) | (FW2X_LED_BLINK << 2) | (FW2X_LED_BLINK << 4)):
|
||||
(FW2X_LED_DEFAULT));
|
||||
aq_hw_fw_version ver_expected = { .raw = FW2X_FW_MIN_VER_LED};
|
||||
if (aq_hw_ver_match(&ver_expected, &hw->fw_version))
|
||||
AQ_WRITE_REG(hw, FW2X_MPI_LED_ADDR,
|
||||
(onoff) ? ((FW2X_LED_BLINK) | (FW2X_LED_BLINK << 2) | (FW2X_LED_BLINK << 4)):
|
||||
(FW2X_LED_DEFAULT));
|
||||
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
struct aq_firmware_ops aq_fw2x_ops =
|
||||
{
|
||||
.reset = fw2x_reset,
|
||||
.reset = fw2x_reset,
|
||||
|
||||
.set_mode = fw2x_set_mode,
|
||||
.get_mode = fw2x_get_mode,
|
||||
.set_mode = fw2x_set_mode,
|
||||
.get_mode = fw2x_get_mode,
|
||||
|
||||
.get_mac_addr = fw2x_get_mac_addr,
|
||||
.get_stats = fw2x_get_stats,
|
||||
.get_mac_addr = fw2x_get_mac_addr,
|
||||
.get_stats = fw2x_get_stats,
|
||||
|
||||
.led_control = fw2x_led_control,
|
||||
.led_control = fw2x_led_control,
|
||||
};
|
||||
|
||||
+516
-503
File diff suppressed because it is too large
Load Diff
+118
-114
@@ -43,24 +43,25 @@
|
||||
#include "aq_common.h"
|
||||
|
||||
#define AQ_WRITE_REG(hw, reg, value) writel(((hw)->hw_addr + (reg)), htole32(value))
|
||||
|
||||
|
||||
#define AQ_READ_REG(hw, reg) le32toh(readl((hw)->hw_addr + reg))
|
||||
|
||||
|
||||
#define AQ_WRITE_REG_BIT(hw, reg, msk, shift, value) do { \
|
||||
if (msk ^ ~0) { \
|
||||
u32 reg_old, reg_new = 0U; \
|
||||
reg_old = AQ_READ_REG(hw, reg); \
|
||||
reg_new = (reg_old & (~msk)) | (value << shift); \
|
||||
if (reg_old != reg_new) \
|
||||
AQ_WRITE_REG(hw, reg, reg_new); \
|
||||
} else { \
|
||||
AQ_WRITE_REG(hw, reg, value); \
|
||||
} } while(0)
|
||||
if (msk ^ ~0) { \
|
||||
uint32_t reg_old, reg_new = 0U; \
|
||||
reg_old = AQ_READ_REG(hw, reg); \
|
||||
reg_new = (reg_old & (~msk)) | (value << shift); \
|
||||
if (reg_old != reg_new) \
|
||||
AQ_WRITE_REG(hw, reg, reg_new); \
|
||||
} else { \
|
||||
AQ_WRITE_REG(hw, reg, value); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define AQ_READ_REG_BIT(a, reg, msk, shift) ( \
|
||||
((AQ_READ_REG(a, reg) & msk) >> shift))
|
||||
((AQ_READ_REG(a, reg) & msk) >> shift))
|
||||
|
||||
#define AQ_HW_FLUSH() { (void)AQ_READ_REG(hw, 0x10); }
|
||||
|
||||
@@ -70,104 +71,104 @@
|
||||
|
||||
/* Statistics */
|
||||
struct aq_hw_stats {
|
||||
u64 crcerrs;
|
||||
uint64_t crcerrs;
|
||||
};
|
||||
|
||||
struct aq_hw_stats_s {
|
||||
u32 uprc;
|
||||
u32 mprc;
|
||||
u32 bprc;
|
||||
u32 erpt;
|
||||
u32 uptc;
|
||||
u32 mptc;
|
||||
u32 bptc;
|
||||
u32 erpr;
|
||||
u32 mbtc;
|
||||
u32 bbtc;
|
||||
u32 mbrc;
|
||||
u32 bbrc;
|
||||
u32 ubrc;
|
||||
u32 ubtc;
|
||||
u32 ptc;
|
||||
u32 prc;
|
||||
u32 dpc;
|
||||
u32 cprc;
|
||||
uint32_t uprc;
|
||||
uint32_t mprc;
|
||||
uint32_t bprc;
|
||||
uint32_t erpt;
|
||||
uint32_t uptc;
|
||||
uint32_t mptc;
|
||||
uint32_t bptc;
|
||||
uint32_t erpr;
|
||||
uint32_t mbtc;
|
||||
uint32_t bbtc;
|
||||
uint32_t mbrc;
|
||||
uint32_t bbrc;
|
||||
uint32_t ubrc;
|
||||
uint32_t ubtc;
|
||||
uint32_t ptc;
|
||||
uint32_t prc;
|
||||
uint32_t dpc;
|
||||
uint32_t cprc;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
union ip_addr {
|
||||
struct {
|
||||
u8 addr[16];
|
||||
} v6;
|
||||
struct {
|
||||
u8 padding[12];
|
||||
u8 addr[4];
|
||||
} v4;
|
||||
struct {
|
||||
uint8_t addr[16];
|
||||
} v6;
|
||||
struct {
|
||||
uint8_t padding[12];
|
||||
uint8_t addr[4];
|
||||
} v4;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct aq_hw_fw_mbox {
|
||||
u32 version;
|
||||
u32 transaction_id;
|
||||
int error;
|
||||
struct aq_hw_stats_s stats;
|
||||
uint32_t version;
|
||||
uint32_t transaction_id;
|
||||
int error;
|
||||
struct aq_hw_stats_s stats;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
typedef struct aq_hw_fw_version {
|
||||
union {
|
||||
struct {
|
||||
u16 build_number;
|
||||
u8 minor_version;
|
||||
u8 major_version;
|
||||
};
|
||||
u32 raw;
|
||||
};
|
||||
union {
|
||||
struct {
|
||||
uint16_t build_number;
|
||||
uint8_t minor_version;
|
||||
uint8_t major_version;
|
||||
};
|
||||
uint32_t raw;
|
||||
};
|
||||
} aq_hw_fw_version;
|
||||
|
||||
enum aq_hw_irq_type {
|
||||
aq_irq_invalid = 0,
|
||||
aq_irq_legacy = 1,
|
||||
aq_irq_msi = 2,
|
||||
aq_irq_msix = 3,
|
||||
aq_irq_invalid = 0,
|
||||
aq_irq_legacy = 1,
|
||||
aq_irq_msi = 2,
|
||||
aq_irq_msix = 3,
|
||||
};
|
||||
|
||||
struct aq_hw_fc_info {
|
||||
bool fc_rx;
|
||||
bool fc_tx;
|
||||
bool fc_rx;
|
||||
bool fc_tx;
|
||||
};
|
||||
|
||||
struct aq_hw {
|
||||
void *aq_dev;
|
||||
u8 *hw_addr;
|
||||
u32 regs_size;
|
||||
void *aq_dev;
|
||||
uint8_t *hw_addr;
|
||||
uint32_t regs_size;
|
||||
|
||||
u8 mac_addr[ETHER_ADDR_LEN];
|
||||
uint8_t mac_addr[ETHER_ADDR_LEN];
|
||||
|
||||
enum aq_hw_irq_type irq_type;
|
||||
|
||||
struct aq_hw_fc_info fc;
|
||||
u16 link_rate;
|
||||
enum aq_hw_irq_type irq_type;
|
||||
|
||||
u16 device_id;
|
||||
u16 subsystem_vendor_id;
|
||||
u16 subsystem_device_id;
|
||||
u16 vendor_id;
|
||||
u8 revision_id;
|
||||
struct aq_hw_fc_info fc;
|
||||
uint16_t link_rate;
|
||||
|
||||
/* Interrupt Moderation value. */
|
||||
int itr;
|
||||
uint16_t device_id;
|
||||
uint16_t subsystem_vendor_id;
|
||||
uint16_t subsystem_device_id;
|
||||
uint16_t vendor_id;
|
||||
uint8_t revision_id;
|
||||
|
||||
/* Firmware-related stuff. */
|
||||
aq_hw_fw_version fw_version;
|
||||
const struct aq_firmware_ops* fw_ops;
|
||||
bool rbl_enabled;
|
||||
bool fast_start_enabled;
|
||||
bool flash_present;
|
||||
u32 chip_features;
|
||||
u64 fw_caps;
|
||||
/* Interrupt Moderation value. */
|
||||
int itr;
|
||||
|
||||
/* Firmware-related stuff. */
|
||||
aq_hw_fw_version fw_version;
|
||||
const struct aq_firmware_ops* fw_ops;
|
||||
bool rbl_enabled;
|
||||
bool fast_start_enabled;
|
||||
bool flash_present;
|
||||
uint32_t chip_features;
|
||||
uint64_t fw_caps;
|
||||
|
||||
bool lro_enabled;
|
||||
|
||||
u32 mbox_addr;
|
||||
struct aq_hw_fw_mbox mbox;
|
||||
uint32_t mbox_addr;
|
||||
struct aq_hw_fw_mbox mbox;
|
||||
};
|
||||
|
||||
#define aq_hw_s aq_hw
|
||||
@@ -217,7 +218,7 @@ struct aq_hw {
|
||||
#define AQ_HW_CHIP_REVISION_B0 0x02000000U
|
||||
#define AQ_HW_CHIP_REVISION_B1 0x04000000U
|
||||
#define IS_CHIP_FEATURE(HW, _F_) (AQ_HW_CHIP_##_F_ & \
|
||||
(HW)->chip_features)
|
||||
(HW)->chip_features)
|
||||
|
||||
#define AQ_HW_FW_VER_EXPECTED 0x01050006U
|
||||
|
||||
@@ -238,22 +239,22 @@ enum hw_atl_rx_action_with_traffic {
|
||||
};
|
||||
|
||||
struct aq_rx_filter_vlan {
|
||||
u8 enable;
|
||||
u8 location;
|
||||
u16 vlan_id;
|
||||
u8 queue;
|
||||
uint8_t enable;
|
||||
uint8_t location;
|
||||
uint16_t vlan_id;
|
||||
uint8_t queue;
|
||||
};
|
||||
|
||||
#define AQ_HW_VLAN_MAX_FILTERS 16U
|
||||
#define AQ_HW_ETYPE_MAX_FILTERS 16U
|
||||
|
||||
struct aq_rx_filter_l2 {
|
||||
u8 enable;
|
||||
s8 queue;
|
||||
u8 location;
|
||||
u8 user_priority_en;
|
||||
u8 user_priority;
|
||||
u16 ethertype;
|
||||
uint8_t enable;
|
||||
int8_t queue;
|
||||
uint8_t location;
|
||||
uint8_t user_priority_en;
|
||||
uint8_t user_priority;
|
||||
uint16_t ethertype;
|
||||
};
|
||||
|
||||
enum hw_atl_rx_ctrl_registers_l2 {
|
||||
@@ -262,12 +263,12 @@ enum hw_atl_rx_ctrl_registers_l2 {
|
||||
};
|
||||
|
||||
struct aq_rx_filter_l3l4 {
|
||||
u32 cmd;
|
||||
u8 location;
|
||||
u32 ip_dst[4];
|
||||
u32 ip_src[4];
|
||||
u16 p_dst;
|
||||
u16 p_src;
|
||||
uint32_t cmd;
|
||||
uint8_t location;
|
||||
uint32_t ip_dst[4];
|
||||
uint32_t ip_src[4];
|
||||
uint16_t p_dst;
|
||||
uint16_t p_src;
|
||||
bool is_ipv6;
|
||||
};
|
||||
|
||||
@@ -301,22 +302,23 @@ enum hw_atl_rx_ctrl_registers_l3l4 {
|
||||
((location) - AQ_RX_FIRST_LOC_FL3L4)
|
||||
|
||||
enum aq_hw_fw_mpi_state_e {
|
||||
MPI_DEINIT = 0,
|
||||
MPI_RESET = 1,
|
||||
MPI_INIT = 2,
|
||||
MPI_POWER = 4,
|
||||
MPI_DEINIT = 0,
|
||||
MPI_RESET = 1,
|
||||
MPI_INIT = 2,
|
||||
MPI_POWER = 4,
|
||||
};
|
||||
|
||||
int aq_hw_get_mac_permanent(struct aq_hw *hw, u8 *mac);
|
||||
int aq_hw_get_mac_permanent(struct aq_hw *hw, uint8_t *mac);
|
||||
|
||||
int aq_hw_mac_addr_set(struct aq_hw *hw, u8 *mac_addr, u8 index);
|
||||
int aq_hw_mac_addr_set(struct aq_hw *hw, uint8_t *mac_addr, uint8_t index);
|
||||
|
||||
/* link speed in mbps. "0" - no link detected */
|
||||
int aq_hw_get_link_state(struct aq_hw *hw, u32 *link_speed, struct aq_hw_fc_info *fc_neg);
|
||||
int aq_hw_get_link_state(struct aq_hw *hw, uint32_t *link_speed,
|
||||
struct aq_hw_fc_info *fc_neg);
|
||||
|
||||
int aq_hw_set_link_speed(struct aq_hw *hw, u32 speed);
|
||||
int aq_hw_set_link_speed(struct aq_hw *hw, uint32_t speed);
|
||||
|
||||
int aq_hw_fw_downld_dwords(struct aq_hw *hw, u32 a, u32 *p, u32 cnt);
|
||||
int aq_hw_fw_downld_dwords(struct aq_hw *hw, uint32_t a, uint32_t *p, uint32_t cnt);
|
||||
|
||||
int aq_hw_reset(struct aq_hw *hw);
|
||||
|
||||
@@ -324,19 +326,21 @@ int aq_hw_mpi_create(struct aq_hw *hw);
|
||||
|
||||
int aq_hw_mpi_read_stats(struct aq_hw *hw, struct aq_hw_fw_mbox *pmbox);
|
||||
|
||||
int aq_hw_init(struct aq_hw *hw, u8 *mac_addr, u8 adm_irq, bool msix);
|
||||
int aq_hw_init(struct aq_hw *hw, uint8_t *mac_addr, uint8_t adm_irq, bool msix);
|
||||
|
||||
int aq_hw_start(struct aq_hw *hw);
|
||||
|
||||
int aq_hw_interrupt_moderation_set(struct aq_hw *hw);
|
||||
|
||||
int aq_hw_get_fw_version(struct aq_hw *hw, u32 *fw_version);
|
||||
int aq_hw_get_fw_version(struct aq_hw *hw, uint32_t *fw_version);
|
||||
|
||||
int aq_hw_deinit(struct aq_hw *hw);
|
||||
|
||||
int aq_hw_ver_match(const aq_hw_fw_version* ver_expected, const aq_hw_fw_version* ver_actual);
|
||||
int aq_hw_ver_match(const aq_hw_fw_version* ver_expected,
|
||||
const aq_hw_fw_version* ver_actual);
|
||||
|
||||
void aq_hw_set_promisc(struct aq_hw_s *self, bool l2_promisc, bool vlan_promisc, bool mc_promisc);
|
||||
void aq_hw_set_promisc(struct aq_hw_s *self, bool l2_promisc, bool vlan_promisc,
|
||||
bool mc_promisc);
|
||||
|
||||
int aq_hw_set_power(struct aq_hw *hw, unsigned int power_state);
|
||||
|
||||
@@ -345,11 +349,11 @@ int aq_hw_err_from_flags(struct aq_hw *hw);
|
||||
int hw_atl_b0_hw_vlan_promisc_set(struct aq_hw_s *self, bool promisc);
|
||||
|
||||
int hw_atl_b0_hw_vlan_set(struct aq_hw_s *self,
|
||||
struct aq_rx_filter_vlan *aq_vlans);
|
||||
struct aq_rx_filter_vlan *aq_vlans);
|
||||
|
||||
int aq_hw_rss_hash_set(struct aq_hw_s *self, u8 rss_key[HW_ATL_RSS_HASHKEY_SIZE]);
|
||||
int aq_hw_rss_hash_get(struct aq_hw_s *self, u8 rss_key[HW_ATL_RSS_HASHKEY_SIZE]);
|
||||
int aq_hw_rss_set(struct aq_hw_s *self, u8 rss_table[HW_ATL_RSS_INDIRECTION_TABLE_MAX]);
|
||||
int aq_hw_rss_hash_set(struct aq_hw_s *self, uint8_t rss_key[HW_ATL_RSS_HASHKEY_SIZE]);
|
||||
int aq_hw_rss_hash_get(struct aq_hw_s *self, uint8_t rss_key[HW_ATL_RSS_HASHKEY_SIZE]);
|
||||
int aq_hw_rss_set(struct aq_hw_s *self, uint8_t rss_table[HW_ATL_RSS_INDIRECTION_TABLE_MAX]);
|
||||
int aq_hw_udp_rss_enable(struct aq_hw_s *self, bool enable);
|
||||
|
||||
#endif //_AQ_HW_H_
|
||||
|
||||
+1100
-1024
File diff suppressed because it is too large
Load Diff
+453
-420
File diff suppressed because it is too large
Load Diff
@@ -3248,7 +3248,7 @@
|
||||
|
||||
/* tx dma descriptor base address msw definitions */
|
||||
#define tx_dma_desc_base_addrmsw_adr(descriptor) \
|
||||
(0x00007c04u + (descriptor) * 0x40)
|
||||
(0x00007c04u + (descriptor) * 0x40)
|
||||
|
||||
/* tx interrupt moderation control register definitions
|
||||
* Preprocessor definitions for TX Interrupt Moderation Control Register
|
||||
|
||||
+42
-40
@@ -37,14 +37,14 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/bitstring.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/bitstring.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/iflib.h>
|
||||
|
||||
#include "aq_common.h"
|
||||
@@ -54,60 +54,60 @@ __FBSDID("$FreeBSD$");
|
||||
#include "aq_hw.h"
|
||||
#include "aq_hw_llh.h"
|
||||
|
||||
int aq_update_hw_stats(aq_dev_t *aq_dev)
|
||||
int
|
||||
aq_update_hw_stats(aq_dev_t *aq_dev)
|
||||
{
|
||||
struct aq_hw *hw = &aq_dev->hw;
|
||||
struct aq_hw_fw_mbox mbox;
|
||||
struct aq_hw *hw = &aq_dev->hw;
|
||||
struct aq_hw_fw_mbox mbox;
|
||||
|
||||
aq_hw_mpi_read_stats(hw, &mbox);
|
||||
aq_hw_mpi_read_stats(hw, &mbox);
|
||||
|
||||
#define AQ_SDELTA(_N_) (aq_dev->curr_stats._N_ += \
|
||||
mbox.stats._N_ - aq_dev->last_stats._N_)
|
||||
if (aq_dev->linkup) {
|
||||
AQ_SDELTA(uprc);
|
||||
AQ_SDELTA(mprc);
|
||||
AQ_SDELTA(bprc);
|
||||
AQ_SDELTA(cprc);
|
||||
AQ_SDELTA(erpt);
|
||||
mbox.stats._N_ - aq_dev->last_stats._N_)
|
||||
if (aq_dev->linkup) {
|
||||
AQ_SDELTA(uprc);
|
||||
AQ_SDELTA(mprc);
|
||||
AQ_SDELTA(bprc);
|
||||
AQ_SDELTA(cprc);
|
||||
AQ_SDELTA(erpt);
|
||||
|
||||
AQ_SDELTA(uptc);
|
||||
AQ_SDELTA(mptc);
|
||||
AQ_SDELTA(bptc);
|
||||
AQ_SDELTA(erpr);
|
||||
AQ_SDELTA(uptc);
|
||||
AQ_SDELTA(mptc);
|
||||
AQ_SDELTA(bptc);
|
||||
AQ_SDELTA(erpr);
|
||||
|
||||
AQ_SDELTA(ubrc);
|
||||
AQ_SDELTA(ubtc);
|
||||
AQ_SDELTA(mbrc);
|
||||
AQ_SDELTA(mbtc);
|
||||
AQ_SDELTA(bbrc);
|
||||
AQ_SDELTA(bbtc);
|
||||
AQ_SDELTA(ubrc);
|
||||
AQ_SDELTA(ubtc);
|
||||
AQ_SDELTA(mbrc);
|
||||
AQ_SDELTA(mbtc);
|
||||
AQ_SDELTA(bbrc);
|
||||
AQ_SDELTA(bbtc);
|
||||
|
||||
AQ_SDELTA(ptc);
|
||||
AQ_SDELTA(prc);
|
||||
AQ_SDELTA(ptc);
|
||||
AQ_SDELTA(prc);
|
||||
|
||||
AQ_SDELTA(dpc);
|
||||
AQ_SDELTA(dpc);
|
||||
|
||||
aq_dev->curr_stats.brc = aq_dev->curr_stats.ubrc +
|
||||
aq_dev->curr_stats.mbrc +
|
||||
aq_dev->curr_stats.bbrc;
|
||||
aq_dev->curr_stats.btc = aq_dev->curr_stats.ubtc +
|
||||
aq_dev->curr_stats.mbtc +
|
||||
aq_dev->curr_stats.bbtc;
|
||||
aq_dev->curr_stats.brc = aq_dev->curr_stats.ubrc +
|
||||
aq_dev->curr_stats.mbrc + aq_dev->curr_stats.bbrc;
|
||||
aq_dev->curr_stats.btc = aq_dev->curr_stats.ubtc +
|
||||
aq_dev->curr_stats.mbtc + aq_dev->curr_stats.bbtc;
|
||||
|
||||
}
|
||||
}
|
||||
#undef AQ_SDELTA
|
||||
|
||||
memcpy(&aq_dev->last_stats, &mbox.stats, sizeof(mbox.stats));
|
||||
memcpy(&aq_dev->last_stats, &mbox.stats, sizeof(mbox.stats));
|
||||
|
||||
return (0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
void aq_if_update_admin_status(if_ctx_t ctx)
|
||||
void
|
||||
aq_if_update_admin_status(if_ctx_t ctx)
|
||||
{
|
||||
aq_dev_t *aq_dev = iflib_get_softc(ctx);
|
||||
struct aq_hw *hw = &aq_dev->hw;
|
||||
u32 link_speed;
|
||||
uint32_t link_speed;
|
||||
|
||||
// AQ_DBG_ENTER();
|
||||
|
||||
@@ -156,7 +156,8 @@ void aq_if_update_admin_status(if_ctx_t ctx)
|
||||
/**************************************************************************/
|
||||
/* interrupt service routine (Top half) */
|
||||
/**************************************************************************/
|
||||
int aq_isr_rx(void *arg)
|
||||
int
|
||||
aq_isr_rx(void *arg)
|
||||
{
|
||||
struct aq_ring *ring = arg;
|
||||
struct aq_dev *aq_dev = ring->dev;
|
||||
@@ -171,7 +172,8 @@ int aq_isr_rx(void *arg)
|
||||
/**************************************************************************/
|
||||
/* interrupt service routine (Top half) */
|
||||
/**************************************************************************/
|
||||
int aq_linkstat_isr(void *arg)
|
||||
int
|
||||
aq_linkstat_isr(void *arg)
|
||||
{
|
||||
aq_dev_t *aq_dev = arg;
|
||||
struct aq_hw *hw = &aq_dev->hw;
|
||||
|
||||
+260
-204
@@ -32,23 +32,26 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_inet6.h"
|
||||
#include "opt_rss.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/sbuf.h>
|
||||
#include <sys/bitstring.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/sbuf.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
@@ -56,18 +59,14 @@ __FBSDID("$FreeBSD$");
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/iflib.h>
|
||||
#include <net/rss_config.h>
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_inet6.h"
|
||||
#include "opt_rss.h"
|
||||
|
||||
#include "ifdi_if.h"
|
||||
|
||||
#include "aq_device.h"
|
||||
@@ -110,25 +109,41 @@ char aq_driver_version[] = AQ_VER;
|
||||
#define AQ_DEVICE_ID_AQC112S 0x92B1
|
||||
|
||||
static pci_vendor_info_t aq_vendor_info_array[] = {
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_0001, "Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_D107, "Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_D108, "Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_D109, "Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_0001,
|
||||
"Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_D107,
|
||||
"Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_D108,
|
||||
"Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_D109,
|
||||
"Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC107, "Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC108, "Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC109, "Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC100, "Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC107,
|
||||
"Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC108,
|
||||
"Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC109,
|
||||
"Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC100,
|
||||
"Aquantia AQtion 10Gbit Network Adapter"),
|
||||
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC107S, "Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC108S, "Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC109S, "Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC100S, "Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC107S,
|
||||
"Aquantia AQtion 10Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC108S,
|
||||
"Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC109S,
|
||||
"Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC100S,
|
||||
"Aquantia AQtion 10Gbit Network Adapter"),
|
||||
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC111, "Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC112, "Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC111S, "Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC112S, "Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC111,
|
||||
"Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC112,
|
||||
"Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC111S,
|
||||
"Aquantia AQtion 5Gbit Network Adapter"),
|
||||
PVID(AQUANTIA_VENDOR_ID, AQ_DEVICE_ID_AQC112S,
|
||||
"Aquantia AQtion 2.5Gbit Network Adapter"),
|
||||
|
||||
PVID_END
|
||||
};
|
||||
@@ -292,19 +307,21 @@ static struct if_shared_ctx aq_sctx_init = {
|
||||
static SYSCTL_NODE(_hw, OID_AUTO, aq, CTLFLAG_RD, 0, "Atlantic driver parameters");
|
||||
/* UDP Receive-Side Scaling */
|
||||
static int aq_enable_rss_udp = 1;
|
||||
SYSCTL_INT(_hw_aq, OID_AUTO, enable_rss_udp, CTLFLAG_RDTUN, &aq_enable_rss_udp, 0,
|
||||
"Enable Receive-Side Scaling (RSS) for UDP");
|
||||
SYSCTL_INT(_hw_aq, OID_AUTO, enable_rss_udp, CTLFLAG_RDTUN, &aq_enable_rss_udp,
|
||||
0, "Enable Receive-Side Scaling (RSS) for UDP");
|
||||
|
||||
|
||||
/*
|
||||
* Device Methods
|
||||
*/
|
||||
static void *aq_register(device_t dev)
|
||||
static void *
|
||||
aq_register(device_t dev)
|
||||
{
|
||||
return (&aq_sctx_init);
|
||||
}
|
||||
|
||||
static int aq_if_attach_pre(if_ctx_t ctx)
|
||||
static int
|
||||
aq_if_attach_pre(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
struct aq_hw *hw;
|
||||
@@ -335,7 +352,7 @@ static int aq_if_attach_pre(if_ctx_t ctx)
|
||||
softc->mmio_tag = rman_get_bustag(softc->mmio_res);
|
||||
softc->mmio_handle = rman_get_bushandle(softc->mmio_res);
|
||||
softc->mmio_size = rman_get_size(softc->mmio_res);
|
||||
softc->hw.hw_addr = (u8*) softc->mmio_handle;
|
||||
softc->hw.hw_addr = (uint8_t*) softc->mmio_handle;
|
||||
hw = &softc->hw;
|
||||
hw->link_rate = aq_fw_speed_auto;
|
||||
hw->itr = -1;
|
||||
@@ -371,22 +388,21 @@ static int aq_if_attach_pre(if_ctx_t ctx)
|
||||
#endif
|
||||
scctx->isc_tx_csum_flags = CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_TSO;
|
||||
#if __FreeBSD__ >= 12
|
||||
scctx->isc_capabilities = IFCAP_RXCSUM | IFCAP_TXCSUM | IFCAP_HWCSUM | IFCAP_TSO |
|
||||
IFCAP_JUMBO_MTU | IFCAP_VLAN_HWFILTER |
|
||||
IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
|
||||
IFCAP_VLAN_HWCSUM;
|
||||
scctx->isc_capabilities = IFCAP_RXCSUM | IFCAP_TXCSUM | IFCAP_HWCSUM |
|
||||
IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_VLAN_HWFILTER | IFCAP_VLAN_MTU |
|
||||
IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWCSUM;
|
||||
scctx->isc_capenable = scctx->isc_capabilities;
|
||||
#else
|
||||
if_t ifp;
|
||||
ifp = iflib_get_ifp(ctx);
|
||||
if_setcapenable(ifp, IFCAP_RXCSUM | IFCAP_TXCSUM | IFCAP_HWCSUM | IFCAP_TSO |
|
||||
IFCAP_JUMBO_MTU | IFCAP_VLAN_HWFILTER |
|
||||
IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
|
||||
IFCAP_VLAN_HWCSUM;
|
||||
if_setcapenable(ifp, IFCAP_RXCSUM | IFCAP_TXCSUM | IFCAP_HWCSUM |
|
||||
IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_VLAN_HWFILTER | IFCAP_VLAN_MTU |
|
||||
IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWCSUM;
|
||||
#endif
|
||||
scctx->isc_tx_nsegments = 31,
|
||||
scctx->isc_tx_tso_segments_max = 31;
|
||||
scctx->isc_tx_tso_size_max = HW_ATL_B0_TSO_SIZE - sizeof(struct ether_vlan_header);
|
||||
scctx->isc_tx_tso_size_max =
|
||||
HW_ATL_B0_TSO_SIZE - sizeof(struct ether_vlan_header);
|
||||
scctx->isc_tx_tso_segsize_max = HW_ATL_B0_MTU_JUMBO;
|
||||
scctx->isc_min_frame_size = 52;
|
||||
scctx->isc_txrx = &aq_txrx;
|
||||
@@ -415,7 +431,8 @@ static int aq_if_attach_pre(if_ctx_t ctx)
|
||||
}
|
||||
|
||||
|
||||
static int aq_if_attach_post(if_ctx_t ctx)
|
||||
static int
|
||||
aq_if_attach_post(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
int rc;
|
||||
@@ -434,7 +451,7 @@ static int aq_if_attach_post(if_ctx_t ctx)
|
||||
case IFLIB_INTR_LEGACY:
|
||||
rc = EOPNOTSUPP;
|
||||
goto exit;
|
||||
goto exit;
|
||||
goto exit;
|
||||
break;
|
||||
case IFLIB_INTR_MSI:
|
||||
break;
|
||||
@@ -458,7 +475,8 @@ static int aq_if_attach_post(if_ctx_t ctx)
|
||||
}
|
||||
|
||||
|
||||
static int aq_if_detach(if_ctx_t ctx)
|
||||
static int
|
||||
aq_if_detach(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
int i;
|
||||
@@ -483,7 +501,8 @@ static int aq_if_detach(if_ctx_t ctx)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int aq_if_shutdown(if_ctx_t ctx)
|
||||
static int
|
||||
aq_if_shutdown(if_ctx_t ctx)
|
||||
{
|
||||
|
||||
AQ_DBG_ENTER();
|
||||
@@ -494,7 +513,8 @@ static int aq_if_shutdown(if_ctx_t ctx)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int aq_if_suspend(if_ctx_t ctx)
|
||||
static int
|
||||
aq_if_suspend(if_ctx_t ctx)
|
||||
{
|
||||
AQ_DBG_ENTER();
|
||||
|
||||
@@ -504,7 +524,8 @@ static int aq_if_suspend(if_ctx_t ctx)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int aq_if_resume(if_ctx_t ctx)
|
||||
static int
|
||||
aq_if_resume(if_ctx_t ctx)
|
||||
{
|
||||
AQ_DBG_ENTER();
|
||||
|
||||
@@ -515,8 +536,9 @@ static int aq_if_resume(if_ctx_t ctx)
|
||||
}
|
||||
|
||||
/* Soft queue setup and teardown */
|
||||
static int aq_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
|
||||
uint64_t *paddrs, int ntxqs, int ntxqsets)
|
||||
static int
|
||||
aq_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs,
|
||||
int ntxqs, int ntxqsets)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
struct aq_ring *ring;
|
||||
@@ -553,8 +575,9 @@ static int aq_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static int aq_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
|
||||
uint64_t *paddrs, int nrxqs, int nrxqsets)
|
||||
static int
|
||||
aq_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs,
|
||||
int nrxqs, int nrxqsets)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
struct aq_ring *ring;
|
||||
@@ -568,7 +591,8 @@ static int aq_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
|
||||
M_AQ, M_NOWAIT | M_ZERO);
|
||||
if (!ring){
|
||||
rc = ENOMEM;
|
||||
device_printf(softc->dev, "atlantic: rx_ring malloc fail\n");
|
||||
device_printf(softc->dev,
|
||||
"atlantic: rx_ring malloc fail\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -601,7 +625,8 @@ static int aq_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static void aq_if_queues_free(if_ctx_t ctx)
|
||||
static void
|
||||
aq_if_queues_free(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
int i;
|
||||
@@ -629,7 +654,8 @@ static void aq_if_queues_free(if_ctx_t ctx)
|
||||
}
|
||||
|
||||
/* Device configuration */
|
||||
static void aq_if_init(if_ctx_t ctx)
|
||||
static void
|
||||
aq_if_init(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
struct aq_hw *hw;
|
||||
@@ -641,7 +667,7 @@ static void aq_if_init(if_ctx_t ctx)
|
||||
hw = &softc->hw;
|
||||
|
||||
err = aq_hw_init(&softc->hw, softc->hw.mac_addr, softc->msix,
|
||||
softc->scctx->isc_intr == IFLIB_INTR_MSIX);
|
||||
softc->scctx->isc_intr == IFLIB_INTR_MSIX);
|
||||
if (err != EOK) {
|
||||
device_printf(softc->dev, "atlantic: aq_hw_init: %d", err);
|
||||
}
|
||||
@@ -654,22 +680,26 @@ static void aq_if_init(if_ctx_t ctx)
|
||||
struct aq_ring *ring = softc->tx_rings[i];
|
||||
err = aq_ring_tx_init(&softc->hw, ring);
|
||||
if (err) {
|
||||
device_printf(softc->dev, "atlantic: aq_ring_tx_init: %d", err);
|
||||
device_printf(softc->dev,
|
||||
"atlantic: aq_ring_tx_init: %d", err);
|
||||
}
|
||||
err = aq_ring_tx_start(hw, ring);
|
||||
if (err != EOK) {
|
||||
device_printf(softc->dev, "atlantic: aq_ring_tx_start: %d", err);
|
||||
device_printf(softc->dev,
|
||||
"atlantic: aq_ring_tx_start: %d", err);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < softc->rx_rings_count; i++) {
|
||||
struct aq_ring *ring = softc->rx_rings[i];
|
||||
err = aq_ring_rx_init(&softc->hw, ring);
|
||||
if (err) {
|
||||
device_printf(softc->dev, "atlantic: aq_ring_rx_init: %d", err);
|
||||
device_printf(softc->dev,
|
||||
"atlantic: aq_ring_rx_init: %d", err);
|
||||
}
|
||||
err = aq_ring_rx_start(hw, ring);
|
||||
if (err != EOK) {
|
||||
device_printf(softc->dev, "atlantic: aq_ring_rx_start: %d", err);
|
||||
device_printf(softc->dev,
|
||||
"atlantic: aq_ring_rx_start: %d", err);
|
||||
}
|
||||
aq_if_rx_queue_intr_enable(ctx, i);
|
||||
}
|
||||
@@ -685,7 +715,8 @@ static void aq_if_init(if_ctx_t ctx)
|
||||
}
|
||||
|
||||
|
||||
static void aq_if_stop(if_ctx_t ctx)
|
||||
static void
|
||||
aq_if_stop(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
struct aq_hw *hw;
|
||||
@@ -715,7 +746,8 @@ static void aq_if_stop(if_ctx_t ctx)
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static uint64_t aq_if_get_counter(if_ctx_t ctx, ift_counter cnt)
|
||||
static uint64_t
|
||||
aq_if_get_counter(if_ctx_t ctx, ift_counter cnt)
|
||||
{
|
||||
struct aq_dev *softc = iflib_get_softc(ctx);
|
||||
if_t ifp = iflib_get_ifp(ctx);
|
||||
@@ -733,11 +765,12 @@ static uint64_t aq_if_get_counter(if_ctx_t ctx, ift_counter cnt)
|
||||
}
|
||||
|
||||
#if __FreeBSD_version >= 1300054
|
||||
static u_int aq_mc_filter_apply(void *arg, struct sockaddr_dl *dl, u_int count)
|
||||
static u_int
|
||||
aq_mc_filter_apply(void *arg, struct sockaddr_dl *dl, u_int count)
|
||||
{
|
||||
struct aq_dev *softc = arg;
|
||||
struct aq_hw *hw = &softc->hw;
|
||||
u8 *mac_addr = NULL;
|
||||
uint8_t *mac_addr = NULL;
|
||||
|
||||
if (count == AQ_HW_MAC_MAX)
|
||||
return (0);
|
||||
@@ -749,11 +782,12 @@ static u_int aq_mc_filter_apply(void *arg, struct sockaddr_dl *dl, u_int count)
|
||||
return (1);
|
||||
}
|
||||
#else
|
||||
static int aq_mc_filter_apply(void *arg, struct ifmultiaddr *ifma, int count)
|
||||
static int
|
||||
aq_mc_filter_apply(void *arg, struct ifmultiaddr *ifma, int count)
|
||||
{
|
||||
struct aq_dev *softc = arg;
|
||||
struct aq_hw *hw = &softc->hw;
|
||||
u8 *mac_addr = NULL;
|
||||
uint8_t *mac_addr = NULL;
|
||||
|
||||
if (ifma->ifma_addr->sa_family != AF_LINK)
|
||||
return (0);
|
||||
@@ -768,12 +802,14 @@ static int aq_mc_filter_apply(void *arg, struct ifmultiaddr *ifma, int count)
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool aq_is_mc_promisc_required(struct aq_dev *softc)
|
||||
static bool
|
||||
aq_is_mc_promisc_required(struct aq_dev *softc)
|
||||
{
|
||||
return (softc->mcnt >= AQ_HW_MAC_MAX);
|
||||
}
|
||||
|
||||
static void aq_if_multi_set(if_ctx_t ctx)
|
||||
static void
|
||||
aq_if_multi_set(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc = iflib_get_softc(ctx);
|
||||
if_t ifp = iflib_get_ifp(ctx);
|
||||
@@ -784,12 +820,11 @@ static void aq_if_multi_set(if_ctx_t ctx)
|
||||
#else
|
||||
softc->mcnt = if_multiaddr_count(iflib_get_ifp(ctx), AQ_HW_MAC_MAX);
|
||||
#endif
|
||||
if (softc->mcnt >= AQ_HW_MAC_MAX)
|
||||
{
|
||||
if (softc->mcnt >= AQ_HW_MAC_MAX) {
|
||||
aq_hw_set_promisc(hw, !!(if_getflags(ifp) & IFF_PROMISC),
|
||||
aq_is_vlan_promisc_required(softc),
|
||||
!!(if_getflags(ifp) & IFF_ALLMULTI) || aq_is_mc_promisc_required(softc));
|
||||
}else{
|
||||
aq_is_vlan_promisc_required(softc),
|
||||
!!(if_getflags(ifp) & IFF_ALLMULTI) || aq_is_mc_promisc_required(softc));
|
||||
} else {
|
||||
#if __FreeBSD_version >= 1300054
|
||||
if_foreach_llmaddr(iflib_get_ifp(ctx), &aq_mc_filter_apply, softc);
|
||||
#else
|
||||
@@ -799,7 +834,8 @@ static void aq_if_multi_set(if_ctx_t ctx)
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static int aq_if_mtu_set(if_ctx_t ctx, uint32_t mtu)
|
||||
static int
|
||||
aq_if_mtu_set(if_ctx_t ctx, uint32_t mtu)
|
||||
{
|
||||
int err = 0;
|
||||
AQ_DBG_ENTER();
|
||||
@@ -808,7 +844,8 @@ static int aq_if_mtu_set(if_ctx_t ctx, uint32_t mtu)
|
||||
return (err);
|
||||
}
|
||||
|
||||
static void aq_if_media_status(if_ctx_t ctx, struct ifmediareq *ifmr)
|
||||
static void
|
||||
aq_if_media_status(if_ctx_t ctx, struct ifmediareq *ifmr)
|
||||
{
|
||||
if_t ifp;
|
||||
|
||||
@@ -821,7 +858,8 @@ static void aq_if_media_status(if_ctx_t ctx, struct ifmediareq *ifmr)
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static int aq_if_media_change(if_ctx_t ctx)
|
||||
static int
|
||||
aq_if_media_change(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc = iflib_get_softc(ctx);
|
||||
if_t ifp = iflib_get_ifp(ctx);
|
||||
@@ -844,7 +882,8 @@ static int aq_if_media_change(if_ctx_t ctx)
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static int aq_if_promisc_set(if_ctx_t ctx, int flags)
|
||||
static int
|
||||
aq_if_promisc_set(if_ctx_t ctx, int flags)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
|
||||
@@ -853,14 +892,15 @@ static int aq_if_promisc_set(if_ctx_t ctx, int flags)
|
||||
softc = iflib_get_softc(ctx);
|
||||
|
||||
aq_hw_set_promisc(&softc->hw, !!(flags & IFF_PROMISC),
|
||||
aq_is_vlan_promisc_required(softc),
|
||||
!!(flags & IFF_ALLMULTI) || aq_is_mc_promisc_required(softc));
|
||||
aq_is_vlan_promisc_required(softc),
|
||||
!!(flags & IFF_ALLMULTI) || aq_is_mc_promisc_required(softc));
|
||||
|
||||
AQ_DBG_EXIT(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void aq_if_timer(if_ctx_t ctx, uint16_t qid)
|
||||
static void
|
||||
aq_if_timer(if_ctx_t ctx, uint16_t qid)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
uint64_t ticks_now;
|
||||
@@ -882,7 +922,8 @@ static void aq_if_timer(if_ctx_t ctx, uint16_t qid)
|
||||
}
|
||||
|
||||
/* Interrupt enable / disable */
|
||||
static void aq_if_enable_intr(if_ctx_t ctx)
|
||||
static void
|
||||
aq_if_enable_intr(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc = iflib_get_softc(ctx);
|
||||
struct aq_hw *hw = &softc->hw;
|
||||
@@ -895,7 +936,8 @@ static void aq_if_enable_intr(if_ctx_t ctx)
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static void aq_if_disable_intr(if_ctx_t ctx)
|
||||
static void
|
||||
aq_if_disable_intr(if_ctx_t ctx)
|
||||
{
|
||||
struct aq_dev *softc = iflib_get_softc(ctx);
|
||||
struct aq_hw *hw = &softc->hw;
|
||||
@@ -908,7 +950,8 @@ static void aq_if_disable_intr(if_ctx_t ctx)
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static int aq_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid)
|
||||
static int
|
||||
aq_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid)
|
||||
{
|
||||
struct aq_dev *softc = iflib_get_softc(ctx);
|
||||
struct aq_hw *hw = &softc->hw;
|
||||
@@ -921,7 +964,8 @@ static int aq_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int aq_if_msix_intr_assign(if_ctx_t ctx, int msix)
|
||||
static int
|
||||
aq_if_msix_intr_assign(if_ctx_t ctx, int msix)
|
||||
{
|
||||
struct aq_dev *softc;
|
||||
int i, vector = 0, rc;
|
||||
@@ -952,22 +996,22 @@ static int aq_if_msix_intr_assign(if_ctx_t ctx, int msix)
|
||||
|
||||
for (i = 0; i < softc->tx_rings_count; i++, vector++) {
|
||||
snprintf(irq_name, sizeof(irq_name), "txq%d", i);
|
||||
iflib_softirq_alloc_generic(ctx, &softc->rx_rings[i]->irq, IFLIB_INTR_TX,
|
||||
softc->tx_rings[i], i, irq_name);
|
||||
iflib_softirq_alloc_generic(ctx, &softc->rx_rings[i]->irq,
|
||||
IFLIB_INTR_TX, softc->tx_rings[i], i, irq_name);
|
||||
|
||||
softc->tx_rings[i]->msix = (vector % softc->rx_rings_count);
|
||||
device_printf(softc->dev, "Assign IRQ %u to tx ring %u\n",
|
||||
softc->tx_rings[i]->msix, softc->tx_rings[i]->index);
|
||||
softc->tx_rings[i]->msix, softc->tx_rings[i]->index);
|
||||
}
|
||||
|
||||
rc = iflib_irq_alloc_generic(ctx, &softc->irq, rx_vectors + 1,
|
||||
IFLIB_INTR_ADMIN, aq_linkstat_isr,
|
||||
softc, 0, "aq");
|
||||
IFLIB_INTR_ADMIN, aq_linkstat_isr, softc, 0, "aq");
|
||||
softc->msix = rx_vectors;
|
||||
device_printf(softc->dev, "Assign IRQ %u to admin proc \n",
|
||||
rx_vectors);
|
||||
rx_vectors);
|
||||
if (rc) {
|
||||
device_printf(iflib_get_dev(ctx), "Failed to register admin handler");
|
||||
device_printf(iflib_get_dev(ctx),
|
||||
"Failed to register admin handler");
|
||||
i = softc->rx_rings_count;
|
||||
goto fail;
|
||||
}
|
||||
@@ -981,7 +1025,8 @@ static int aq_if_msix_intr_assign(if_ctx_t ctx, int msix)
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static bool aq_is_vlan_promisc_required(struct aq_dev *softc)
|
||||
static bool
|
||||
aq_is_vlan_promisc_required(struct aq_dev *softc)
|
||||
{
|
||||
int vlan_tag_count;
|
||||
|
||||
@@ -994,7 +1039,8 @@ static bool aq_is_vlan_promisc_required(struct aq_dev *softc)
|
||||
|
||||
}
|
||||
|
||||
static void aq_update_vlan_filters(struct aq_dev *softc)
|
||||
static void
|
||||
aq_update_vlan_filters(struct aq_dev *softc)
|
||||
{
|
||||
struct aq_rx_filter_vlan aq_vlans[AQ_HW_VLAN_MAX_FILTERS];
|
||||
struct aq_hw *hw = &softc->hw;
|
||||
@@ -1021,7 +1067,8 @@ static void aq_update_vlan_filters(struct aq_dev *softc)
|
||||
}
|
||||
|
||||
/* VLAN support */
|
||||
static void aq_if_vlan_register(if_ctx_t ctx, uint16_t vtag)
|
||||
static void
|
||||
aq_if_vlan_register(if_ctx_t ctx, uint16_t vtag)
|
||||
{
|
||||
struct aq_dev *softc = iflib_get_softc(ctx);
|
||||
|
||||
@@ -1034,7 +1081,8 @@ static void aq_if_vlan_register(if_ctx_t ctx, uint16_t vtag)
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static void aq_if_vlan_unregister(if_ctx_t ctx, uint16_t vtag)
|
||||
static void
|
||||
aq_if_vlan_unregister(if_ctx_t ctx, uint16_t vtag)
|
||||
{
|
||||
struct aq_dev *softc = iflib_get_softc(ctx);
|
||||
|
||||
@@ -1047,7 +1095,8 @@ static void aq_if_vlan_unregister(if_ctx_t ctx, uint16_t vtag)
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static void aq_if_led_func(if_ctx_t ctx, int onoff)
|
||||
static void
|
||||
aq_if_led_func(if_ctx_t ctx, int onoff)
|
||||
{
|
||||
struct aq_dev *softc = iflib_get_softc(ctx);
|
||||
struct aq_hw *hw = &softc->hw;
|
||||
@@ -1059,7 +1108,8 @@ static void aq_if_led_func(if_ctx_t ctx, int onoff)
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static int aq_hw_capabilities(struct aq_dev *softc)
|
||||
static int
|
||||
aq_hw_capabilities(struct aq_dev *softc)
|
||||
{
|
||||
|
||||
if (pci_get_vendor(softc->dev) != AQUANTIA_VENDOR_ID)
|
||||
@@ -1106,7 +1156,8 @@ static int aq_hw_capabilities(struct aq_dev *softc)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int aq_sysctl_print_rss_config(SYSCTL_HANDLER_ARGS)
|
||||
static int
|
||||
aq_sysctl_print_rss_config(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct aq_dev *softc = (struct aq_dev *)arg1;
|
||||
device_t dev = softc->dev;
|
||||
@@ -1142,7 +1193,8 @@ static int aq_sysctl_print_rss_config(SYSCTL_HANDLER_ARGS)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int aq_sysctl_print_tx_head(SYSCTL_HANDLER_ARGS)
|
||||
static int
|
||||
aq_sysctl_print_tx_head(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct aq_ring *ring = arg1;
|
||||
int error = 0;
|
||||
@@ -1160,7 +1212,8 @@ static int aq_sysctl_print_tx_head(SYSCTL_HANDLER_ARGS)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int aq_sysctl_print_tx_tail(SYSCTL_HANDLER_ARGS)
|
||||
static int
|
||||
aq_sysctl_print_tx_tail(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct aq_ring *ring = arg1;
|
||||
int error = 0;
|
||||
@@ -1178,7 +1231,8 @@ static int aq_sysctl_print_tx_tail(SYSCTL_HANDLER_ARGS)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int aq_sysctl_print_rx_head(SYSCTL_HANDLER_ARGS)
|
||||
static int
|
||||
aq_sysctl_print_rx_head(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct aq_ring *ring = arg1;
|
||||
int error = 0;
|
||||
@@ -1196,7 +1250,8 @@ static int aq_sysctl_print_rx_head(SYSCTL_HANDLER_ARGS)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int aq_sysctl_print_rx_tail(SYSCTL_HANDLER_ARGS)
|
||||
static int
|
||||
aq_sysctl_print_rx_tail(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct aq_ring *ring = arg1;
|
||||
int error = 0;
|
||||
@@ -1214,116 +1269,117 @@ static int aq_sysctl_print_rx_tail(SYSCTL_HANDLER_ARGS)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void aq_add_stats_sysctls(struct aq_dev *softc)
|
||||
static void
|
||||
aq_add_stats_sysctls(struct aq_dev *softc)
|
||||
{
|
||||
device_t dev = softc->dev;
|
||||
struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev);
|
||||
struct sysctl_oid *tree = device_get_sysctl_tree(dev);
|
||||
struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
|
||||
struct aq_stats_s *stats = &softc->curr_stats;
|
||||
struct sysctl_oid *stat_node, *queue_node;
|
||||
struct sysctl_oid_list *stat_list, *queue_list;
|
||||
device_t dev = softc->dev;
|
||||
struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev);
|
||||
struct sysctl_oid *tree = device_get_sysctl_tree(dev);
|
||||
struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
|
||||
struct aq_stats_s *stats = &softc->curr_stats;
|
||||
struct sysctl_oid *stat_node, *queue_node;
|
||||
struct sysctl_oid_list *stat_list, *queue_list;
|
||||
|
||||
#define QUEUE_NAME_LEN 32
|
||||
char namebuf[QUEUE_NAME_LEN];
|
||||
char namebuf[QUEUE_NAME_LEN];
|
||||
/* RSS configuration */
|
||||
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "print_rss_config",
|
||||
CTLTYPE_STRING | CTLFLAG_RD, softc, 0,
|
||||
aq_sysctl_print_rss_config, "A", "Prints RSS Configuration");
|
||||
CTLTYPE_STRING | CTLFLAG_RD, softc, 0,
|
||||
aq_sysctl_print_rss_config, "A", "Prints RSS Configuration");
|
||||
|
||||
/* Driver Statistics */
|
||||
for (int i = 0; i < softc->tx_rings_count; i++) {
|
||||
struct aq_ring *ring = softc->tx_rings[i];
|
||||
snprintf(namebuf, QUEUE_NAME_LEN, "tx_queue%d", i);
|
||||
queue_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, namebuf,
|
||||
CTLFLAG_RD, NULL, "Queue Name");
|
||||
queue_list = SYSCTL_CHILDREN(queue_node);
|
||||
/* Driver Statistics */
|
||||
for (int i = 0; i < softc->tx_rings_count; i++) {
|
||||
struct aq_ring *ring = softc->tx_rings[i];
|
||||
snprintf(namebuf, QUEUE_NAME_LEN, "tx_queue%d", i);
|
||||
queue_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, namebuf,
|
||||
CTLFLAG_RD, NULL, "Queue Name");
|
||||
queue_list = SYSCTL_CHILDREN(queue_node);
|
||||
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_pkts",
|
||||
CTLFLAG_RD, &(ring->stats.tx_pkts), "TX Packets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_bytes",
|
||||
CTLFLAG_RD, &(ring->stats.tx_bytes), "TX Octets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_drops",
|
||||
CTLFLAG_RD, &(ring->stats.tx_drops), "TX Drops");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_queue_full",
|
||||
CTLFLAG_RD, &(ring->stats.tx_queue_full), "TX Queue Full");
|
||||
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "tx_head",
|
||||
CTLTYPE_UINT | CTLFLAG_RD, ring, 0,
|
||||
aq_sysctl_print_tx_head, "IU", "ring head pointer");
|
||||
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "tx_tail",
|
||||
CTLTYPE_UINT | CTLFLAG_RD, ring, 0,
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_pkts",
|
||||
CTLFLAG_RD, &(ring->stats.tx_pkts), "TX Packets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_bytes",
|
||||
CTLFLAG_RD, &(ring->stats.tx_bytes), "TX Octets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_drops",
|
||||
CTLFLAG_RD, &(ring->stats.tx_drops), "TX Drops");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_queue_full",
|
||||
CTLFLAG_RD, &(ring->stats.tx_queue_full), "TX Queue Full");
|
||||
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "tx_head",
|
||||
CTLTYPE_UINT | CTLFLAG_RD, ring, 0,
|
||||
aq_sysctl_print_tx_head, "IU", "ring head pointer");
|
||||
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "tx_tail",
|
||||
CTLTYPE_UINT | CTLFLAG_RD, ring, 0,
|
||||
aq_sysctl_print_tx_tail, "IU", "ring tail pointer");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < softc->rx_rings_count; i++) {
|
||||
struct aq_ring *ring = softc->rx_rings[i];
|
||||
snprintf(namebuf, QUEUE_NAME_LEN, "rx_queue%d", i);
|
||||
queue_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, namebuf,
|
||||
CTLFLAG_RD, NULL, "Queue Name");
|
||||
queue_list = SYSCTL_CHILDREN(queue_node);
|
||||
for (int i = 0; i < softc->rx_rings_count; i++) {
|
||||
struct aq_ring *ring = softc->rx_rings[i];
|
||||
snprintf(namebuf, QUEUE_NAME_LEN, "rx_queue%d", i);
|
||||
queue_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, namebuf,
|
||||
CTLFLAG_RD, NULL, "Queue Name");
|
||||
queue_list = SYSCTL_CHILDREN(queue_node);
|
||||
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "rx_pkts",
|
||||
CTLFLAG_RD, &(ring->stats.rx_pkts), "RX Packets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "rx_bytes",
|
||||
CTLFLAG_RD, &(ring->stats.rx_bytes), "TX Octets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "jumbo_pkts",
|
||||
CTLFLAG_RD, &(ring->stats.jumbo_pkts), "Jumbo Packets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "rx_err",
|
||||
CTLFLAG_RD, &(ring->stats.rx_err), "RX Errors");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "irq",
|
||||
CTLFLAG_RD, &(ring->stats.irq), "RX interrupts");
|
||||
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "rx_head",
|
||||
CTLTYPE_UINT | CTLFLAG_RD, ring, 0,
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "rx_pkts",
|
||||
CTLFLAG_RD, &(ring->stats.rx_pkts), "RX Packets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "rx_bytes",
|
||||
CTLFLAG_RD, &(ring->stats.rx_bytes), "TX Octets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "jumbo_pkts",
|
||||
CTLFLAG_RD, &(ring->stats.jumbo_pkts), "Jumbo Packets");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "rx_err",
|
||||
CTLFLAG_RD, &(ring->stats.rx_err), "RX Errors");
|
||||
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "irq",
|
||||
CTLFLAG_RD, &(ring->stats.irq), "RX interrupts");
|
||||
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "rx_head",
|
||||
CTLTYPE_UINT | CTLFLAG_RD, ring, 0,
|
||||
aq_sysctl_print_rx_head, "IU", "ring head pointer");
|
||||
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "rx_tail",
|
||||
CTLTYPE_UINT | CTLFLAG_RD, ring, 0,
|
||||
SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "rx_tail",
|
||||
CTLTYPE_UINT | CTLFLAG_RD, ring, 0,
|
||||
aq_sysctl_print_rx_tail, "IU", " ring tail pointer");
|
||||
}
|
||||
}
|
||||
|
||||
stat_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "mac",
|
||||
CTLFLAG_RD, NULL, "Statistics (read from HW registers)");
|
||||
stat_list = SYSCTL_CHILDREN(stat_node);
|
||||
stat_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "mac",
|
||||
CTLFLAG_RD, NULL, "Statistics (read from HW registers)");
|
||||
stat_list = SYSCTL_CHILDREN(stat_node);
|
||||
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->prc, "Good Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "ucast_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->uprc, "Unicast Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->mprc, "Multicast Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->bprc, "Broadcast Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "rsc_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->cprc, "Coalesced Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "err_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->erpr, "Errors of Packet Receive");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "drop_pkts_dma",
|
||||
CTLFLAG_RD, &stats->dpc, "Dropped Packets in DMA");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_octets_rcvd",
|
||||
CTLFLAG_RD, &stats->brc, "Good Octets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "ucast_octets_rcvd",
|
||||
CTLFLAG_RD, &stats->ubrc, "Unicast Octets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_octets_rcvd",
|
||||
CTLFLAG_RD, &stats->mbrc, "Multicast Octets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_octets_rcvd",
|
||||
CTLFLAG_RD, &stats->bbrc, "Broadcast Octets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->prc, "Good Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "ucast_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->uprc, "Unicast Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->mprc, "Multicast Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->bprc, "Broadcast Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "rsc_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->cprc, "Coalesced Packets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "err_pkts_rcvd",
|
||||
CTLFLAG_RD, &stats->erpr, "Errors of Packet Receive");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "drop_pkts_dma",
|
||||
CTLFLAG_RD, &stats->dpc, "Dropped Packets in DMA");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_octets_rcvd",
|
||||
CTLFLAG_RD, &stats->brc, "Good Octets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "ucast_octets_rcvd",
|
||||
CTLFLAG_RD, &stats->ubrc, "Unicast Octets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_octets_rcvd",
|
||||
CTLFLAG_RD, &stats->mbrc, "Multicast Octets Received");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_octets_rcvd",
|
||||
CTLFLAG_RD, &stats->bbrc, "Broadcast Octets Received");
|
||||
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_pkts_txd",
|
||||
CTLFLAG_RD, &stats->ptc, "Good Packets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "ucast_pkts_txd",
|
||||
CTLFLAG_RD, &stats->uptc, "Unicast Packets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_pkts_txd",
|
||||
CTLFLAG_RD, &stats->mptc, "Multicast Packets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_pkts_txd",
|
||||
CTLFLAG_RD, &stats->bptc, "Broadcast Packets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_pkts_txd",
|
||||
CTLFLAG_RD, &stats->ptc, "Good Packets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "ucast_pkts_txd",
|
||||
CTLFLAG_RD, &stats->uptc, "Unicast Packets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_pkts_txd",
|
||||
CTLFLAG_RD, &stats->mptc, "Multicast Packets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_pkts_txd",
|
||||
CTLFLAG_RD, &stats->bptc, "Broadcast Packets Transmitted");
|
||||
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "err_pkts_txd",
|
||||
CTLFLAG_RD, &stats->erpt, "Errors of Packet Transmit");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_octets_txd",
|
||||
CTLFLAG_RD, &stats->btc, "Good Octets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "ucast_octets_txd",
|
||||
CTLFLAG_RD, &stats->ubtc, "Unicast Octets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_octets_txd",
|
||||
CTLFLAG_RD, &stats->mbtc, "Multicast Octets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_octets_txd",
|
||||
CTLFLAG_RD, &stats->bbtc, "Broadcast Octets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "err_pkts_txd",
|
||||
CTLFLAG_RD, &stats->erpt, "Errors of Packet Transmit");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_octets_txd",
|
||||
CTLFLAG_RD, &stats->btc, "Good Octets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "ucast_octets_txd",
|
||||
CTLFLAG_RD, &stats->ubtc, "Unicast Octets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "mcast_octets_txd",
|
||||
CTLFLAG_RD, &stats->mbtc, "Multicast Octets Transmitted");
|
||||
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_octets_txd",
|
||||
CTLFLAG_RD, &stats->bbtc, "Broadcast Octets Transmitted");
|
||||
}
|
||||
|
||||
+30
-26
@@ -36,14 +36,14 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/bitstring.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/bitstring.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/iflib.h>
|
||||
|
||||
#include "aq_device.h"
|
||||
@@ -53,48 +53,46 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#define AQ_HW_SUPPORT_SPEED(softc, s) ((softc)->link_speeds & s)
|
||||
|
||||
void aq_mediastatus_update(aq_dev_t *aq_dev, u32 link_speed, const struct aq_hw_fc_info *fc_neg)
|
||||
void
|
||||
aq_mediastatus_update(aq_dev_t *aq_dev, uint32_t link_speed,
|
||||
const struct aq_hw_fc_info *fc_neg)
|
||||
{
|
||||
struct aq_hw *hw = &aq_dev->hw;
|
||||
|
||||
aq_dev->media_active = 0;
|
||||
if (fc_neg->fc_rx)
|
||||
aq_dev->media_active |= IFM_ETH_RXPAUSE;
|
||||
aq_dev->media_active |= IFM_ETH_RXPAUSE;
|
||||
if (fc_neg->fc_tx)
|
||||
aq_dev->media_active |= IFM_ETH_TXPAUSE;
|
||||
aq_dev->media_active |= IFM_ETH_TXPAUSE;
|
||||
|
||||
switch(link_speed) {
|
||||
case 100:
|
||||
aq_dev->media_active |= IFM_100_TX | IFM_FDX;
|
||||
break;
|
||||
|
||||
break;
|
||||
case 1000:
|
||||
aq_dev->media_active |= IFM_1000_T | IFM_FDX;
|
||||
break;
|
||||
|
||||
break;
|
||||
case 2500:
|
||||
aq_dev->media_active |= IFM_2500_T | IFM_FDX;
|
||||
break;
|
||||
|
||||
break;
|
||||
case 5000:
|
||||
aq_dev->media_active |= IFM_5000_T | IFM_FDX;
|
||||
break;
|
||||
|
||||
break;
|
||||
case 10000:
|
||||
aq_dev->media_active |= IFM_10G_T | IFM_FDX;
|
||||
break;
|
||||
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
aq_dev->media_active |= IFM_NONE;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hw->link_rate == aq_fw_speed_auto)
|
||||
aq_dev->media_active |= IFM_AUTO;
|
||||
}
|
||||
|
||||
void aq_mediastatus(if_t ifp, struct ifmediareq *ifmr)
|
||||
void
|
||||
aq_mediastatus(if_t ifp, struct ifmediareq *ifmr)
|
||||
{
|
||||
aq_dev_t *aq_dev = iflib_get_softc(if_getsoftc(ifp));
|
||||
|
||||
@@ -107,7 +105,8 @@ void aq_mediastatus(if_t ifp, struct ifmediareq *ifmr)
|
||||
ifmr->ifm_active |= aq_dev->media_active;
|
||||
}
|
||||
|
||||
int aq_mediachange(if_t ifp)
|
||||
int
|
||||
aq_mediachange(if_t ifp)
|
||||
{
|
||||
aq_dev_t *aq_dev = iflib_get_softc(if_getsoftc(ifp));
|
||||
struct aq_hw *hw = &aq_dev->hw;
|
||||
@@ -172,7 +171,8 @@ int aq_mediachange(if_t ifp)
|
||||
if (!(if_getflags(ifp) & IFF_UP))
|
||||
return (0);
|
||||
|
||||
if ((media_rate != old_media_rate) || (hw->link_rate != old_link_speed)) {
|
||||
if ((media_rate != old_media_rate) ||
|
||||
(hw->link_rate != old_link_speed)) {
|
||||
// re-initialize hardware with new parameters
|
||||
aq_hw_set_link_speed(hw, hw->link_rate);
|
||||
}
|
||||
@@ -181,17 +181,20 @@ int aq_mediachange(if_t ifp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void aq_add_media_types(aq_dev_t *aq_dev, int media_link_speed)
|
||||
static void
|
||||
aq_add_media_types(aq_dev_t *aq_dev, int media_link_speed)
|
||||
{
|
||||
ifmedia_add(aq_dev->media, IFM_ETHER | media_link_speed | IFM_FDX, 0, NULL);
|
||||
ifmedia_add(aq_dev->media, IFM_ETHER | media_link_speed | IFM_FDX, 0,
|
||||
NULL);
|
||||
ifmedia_add(aq_dev->media, IFM_ETHER | media_link_speed | IFM_FDX |
|
||||
IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL);
|
||||
IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL);
|
||||
ifmedia_add(aq_dev->media, IFM_ETHER | media_link_speed | IFM_FDX |
|
||||
IFM_ETH_RXPAUSE, 0, NULL);
|
||||
IFM_ETH_RXPAUSE, 0, NULL);
|
||||
ifmedia_add(aq_dev->media, IFM_ETHER | media_link_speed | IFM_FDX |
|
||||
IFM_ETH_TXPAUSE, 0, NULL);
|
||||
IFM_ETH_TXPAUSE, 0, NULL);
|
||||
}
|
||||
void aq_initmedia(aq_dev_t *aq_dev)
|
||||
void
|
||||
aq_initmedia(aq_dev_t *aq_dev)
|
||||
{
|
||||
AQ_DBG_ENTER();
|
||||
|
||||
@@ -213,7 +216,8 @@ void aq_initmedia(aq_dev_t *aq_dev)
|
||||
aq_add_media_types(aq_dev, IFM_10G_T);
|
||||
|
||||
// link is initially autoselect
|
||||
ifmedia_set(aq_dev->media, IFM_ETHER | IFM_AUTO | IFM_FDX | IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE);
|
||||
ifmedia_set(aq_dev->media,
|
||||
IFM_ETHER | IFM_AUTO | IFM_FDX | IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE);
|
||||
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
+153
-131
@@ -36,15 +36,15 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <machine/param.h>
|
||||
#include <sys/bitstring.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/bitstring.h>
|
||||
#include <machine/param.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/iflib.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
@@ -80,151 +80,159 @@ struct if_txrx aq_txrx = {
|
||||
static inline uint32_t
|
||||
aq_next(uint32_t i, uint32_t lim)
|
||||
{
|
||||
return (i == lim) ? 0 : i + 1;
|
||||
return (i == lim) ? 0 : i + 1;
|
||||
}
|
||||
|
||||
int aq_ring_rx_init(struct aq_hw *hw, struct aq_ring *ring)
|
||||
int
|
||||
aq_ring_rx_init(struct aq_hw *hw, struct aq_ring *ring)
|
||||
/* uint64_t ring_addr,
|
||||
u32 ring_size,
|
||||
u32 ring_idx,
|
||||
u32 interrupt_cause,
|
||||
u32 cpu_idx) */
|
||||
uint32_t ring_size,
|
||||
uint32_t ring_idx,
|
||||
uint32_t interrupt_cause,
|
||||
uint32_t cpu_idx) */
|
||||
{
|
||||
int err;
|
||||
u32 dma_desc_addr_lsw = (u32)ring->rx_descs_phys & 0xffffffff;
|
||||
u32 dma_desc_addr_msw = (u32)(ring->rx_descs_phys >> 32);
|
||||
int err;
|
||||
uint32_t dma_desc_addr_lsw = (uint32_t)ring->rx_descs_phys & 0xffffffff;
|
||||
uint32_t dma_desc_addr_msw = (uint32_t)(ring->rx_descs_phys >> 32);
|
||||
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
|
||||
rdm_rx_desc_en_set(hw, false, ring->index);
|
||||
rdm_rx_desc_en_set(hw, false, ring->index);
|
||||
|
||||
rdm_rx_desc_head_splitting_set(hw, 0U, ring->index);
|
||||
rdm_rx_desc_head_splitting_set(hw, 0U, ring->index);
|
||||
|
||||
reg_rx_dma_desc_base_addresslswset(hw, dma_desc_addr_lsw, ring->index);
|
||||
reg_rx_dma_desc_base_addresslswset(hw, dma_desc_addr_lsw, ring->index);
|
||||
|
||||
reg_rx_dma_desc_base_addressmswset(hw, dma_desc_addr_msw, ring->index);
|
||||
reg_rx_dma_desc_base_addressmswset(hw, dma_desc_addr_msw, ring->index);
|
||||
|
||||
rdm_rx_desc_len_set(hw, ring->rx_size / 8U, ring->index);
|
||||
rdm_rx_desc_len_set(hw, ring->rx_size / 8U, ring->index);
|
||||
|
||||
device_printf(ring->dev->dev, "ring %d: __PAGESIZE=%d MCLBYTES=%d hw->max_frame_size=%d\n",
|
||||
device_printf(ring->dev->dev, "ring %d: __PAGESIZE=%d MCLBYTES=%d hw->max_frame_size=%d\n",
|
||||
ring->index, PAGE_SIZE, MCLBYTES, ring->rx_max_frame_size);
|
||||
rdm_rx_desc_data_buff_size_set(hw, ring->rx_max_frame_size / 1024U, ring->index);
|
||||
rdm_rx_desc_data_buff_size_set(hw, ring->rx_max_frame_size / 1024U, ring->index);
|
||||
|
||||
rdm_rx_desc_head_buff_size_set(hw, 0U, ring->index);
|
||||
rdm_rx_desc_head_splitting_set(hw, 0U, ring->index);
|
||||
rpo_rx_desc_vlan_stripping_set(hw, 0U, ring->index);
|
||||
rdm_rx_desc_head_buff_size_set(hw, 0U, ring->index);
|
||||
rdm_rx_desc_head_splitting_set(hw, 0U, ring->index);
|
||||
rpo_rx_desc_vlan_stripping_set(hw, 0U, ring->index);
|
||||
|
||||
/* Rx ring set mode */
|
||||
/* Rx ring set mode */
|
||||
|
||||
/* Mapping interrupt vector */
|
||||
itr_irq_map_rx_set(hw, ring->msix, ring->index);
|
||||
itr_irq_map_en_rx_set(hw, true, ring->index);
|
||||
/* Mapping interrupt vector */
|
||||
itr_irq_map_rx_set(hw, ring->msix, ring->index);
|
||||
itr_irq_map_en_rx_set(hw, true, ring->index);
|
||||
|
||||
rdm_cpu_id_set(hw, 0, ring->index);
|
||||
rdm_rx_desc_dca_en_set(hw, 0U, ring->index);
|
||||
rdm_rx_head_dca_en_set(hw, 0U, ring->index);
|
||||
rdm_rx_pld_dca_en_set(hw, 0U, ring->index);
|
||||
rdm_cpu_id_set(hw, 0, ring->index);
|
||||
rdm_rx_desc_dca_en_set(hw, 0U, ring->index);
|
||||
rdm_rx_head_dca_en_set(hw, 0U, ring->index);
|
||||
rdm_rx_pld_dca_en_set(hw, 0U, ring->index);
|
||||
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
int aq_ring_tx_init(struct aq_hw *hw, struct aq_ring *ring)
|
||||
int
|
||||
aq_ring_tx_init(struct aq_hw *hw, struct aq_ring *ring)
|
||||
/* uint64_t ring_addr,
|
||||
u32 ring_size,
|
||||
u32 ring_idx,
|
||||
u32 interrupt_cause,
|
||||
u32 cpu_idx) */
|
||||
uint32_t ring_size,
|
||||
uint32_t ring_idx,
|
||||
uint32_t interrupt_cause,
|
||||
uint32_t cpu_idx) */
|
||||
{
|
||||
int err;
|
||||
u32 dma_desc_addr_lsw = (u32)ring->tx_descs_phys & 0xffffffff;
|
||||
u32 dma_desc_addr_msw = (u64)(ring->tx_descs_phys >> 32);
|
||||
int err;
|
||||
uint32_t dma_desc_addr_lsw = (uint32_t)ring->tx_descs_phys & 0xffffffff;
|
||||
uint32_t dma_desc_addr_msw = (uint64_t)(ring->tx_descs_phys >> 32);
|
||||
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
|
||||
tdm_tx_desc_en_set(hw, 0U, ring->index);
|
||||
tdm_tx_desc_en_set(hw, 0U, ring->index);
|
||||
|
||||
reg_tx_dma_desc_base_addresslswset(hw, dma_desc_addr_lsw, ring->index);
|
||||
reg_tx_dma_desc_base_addresslswset(hw, dma_desc_addr_lsw, ring->index);
|
||||
|
||||
reg_tx_dma_desc_base_addressmswset(hw, dma_desc_addr_msw, ring->index);
|
||||
reg_tx_dma_desc_base_addressmswset(hw, dma_desc_addr_msw, ring->index);
|
||||
|
||||
tdm_tx_desc_len_set(hw, ring->tx_size / 8U, ring->index);
|
||||
tdm_tx_desc_len_set(hw, ring->tx_size / 8U, ring->index);
|
||||
|
||||
aq_ring_tx_tail_update(hw, ring, 0U);
|
||||
aq_ring_tx_tail_update(hw, ring, 0U);
|
||||
|
||||
/* Set Tx threshold */
|
||||
tdm_tx_desc_wr_wb_threshold_set(hw, 0U, ring->index);
|
||||
/* Set Tx threshold */
|
||||
tdm_tx_desc_wr_wb_threshold_set(hw, 0U, ring->index);
|
||||
|
||||
/* Mapping interrupt vector */
|
||||
itr_irq_map_tx_set(hw, ring->msix, ring->index);
|
||||
itr_irq_map_en_tx_set(hw, true, ring->index);
|
||||
/* Mapping interrupt vector */
|
||||
itr_irq_map_tx_set(hw, ring->msix, ring->index);
|
||||
itr_irq_map_en_tx_set(hw, true, ring->index);
|
||||
|
||||
tdm_cpu_id_set(hw, 0, ring->index);
|
||||
tdm_tx_desc_dca_en_set(hw, 0U, ring->index);
|
||||
tdm_cpu_id_set(hw, 0, ring->index);
|
||||
tdm_tx_desc_dca_en_set(hw, 0U, ring->index);
|
||||
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
int aq_ring_tx_tail_update(struct aq_hw *hw, struct aq_ring *ring, u32 tail)
|
||||
int
|
||||
aq_ring_tx_tail_update(struct aq_hw *hw, struct aq_ring *ring, uint32_t tail)
|
||||
{
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
reg_tx_dma_desc_tail_ptr_set(hw, tail, ring->index);
|
||||
AQ_DBG_EXIT(0);
|
||||
return (0);
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
reg_tx_dma_desc_tail_ptr_set(hw, tail, ring->index);
|
||||
AQ_DBG_EXIT(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int aq_ring_tx_start(struct aq_hw *hw, struct aq_ring *ring)
|
||||
int
|
||||
aq_ring_tx_start(struct aq_hw *hw, struct aq_ring *ring)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
tdm_tx_desc_en_set(hw, 1U, ring->index);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
tdm_tx_desc_en_set(hw, 1U, ring->index);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
int aq_ring_rx_start(struct aq_hw *hw, struct aq_ring *ring)
|
||||
int
|
||||
aq_ring_rx_start(struct aq_hw *hw, struct aq_ring *ring)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
rdm_rx_desc_en_set(hw, 1U, ring->index);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
rdm_rx_desc_en_set(hw, 1U, ring->index);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
int aq_ring_tx_stop(struct aq_hw *hw, struct aq_ring *ring)
|
||||
int
|
||||
aq_ring_tx_stop(struct aq_hw *hw, struct aq_ring *ring)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
tdm_tx_desc_en_set(hw, 0U, ring->index);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
tdm_tx_desc_en_set(hw, 0U, ring->index);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
int aq_ring_rx_stop(struct aq_hw *hw, struct aq_ring *ring)
|
||||
int
|
||||
aq_ring_rx_stop(struct aq_hw *hw, struct aq_ring *ring)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
rdm_rx_desc_en_set(hw, 0U, ring->index);
|
||||
/* Invalidate Descriptor Cache to prevent writing to the cached
|
||||
* descriptors and to the data pointer of those descriptors
|
||||
*/
|
||||
rdm_rx_dma_desc_cache_init_tgl(hw);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
AQ_DBG_ENTERA("[%d]", ring->index);
|
||||
rdm_rx_desc_en_set(hw, 0U, ring->index);
|
||||
/* Invalidate Descriptor Cache to prevent writing to the cached
|
||||
* descriptors and to the data pointer of those descriptors
|
||||
*/
|
||||
rdm_rx_dma_desc_cache_init_tgl(hw);
|
||||
err = aq_hw_err_from_flags(hw);
|
||||
AQ_DBG_EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
static void aq_ring_rx_refill(void* arg, if_rxd_update_t iru)
|
||||
static void
|
||||
aq_ring_rx_refill(void* arg, if_rxd_update_t iru)
|
||||
{
|
||||
aq_dev_t *aq_dev = arg;
|
||||
aq_rx_desc_t *rx_desc;
|
||||
@@ -232,7 +240,7 @@ static void aq_ring_rx_refill(void* arg, if_rxd_update_t iru)
|
||||
qidx_t i, pidx;
|
||||
|
||||
AQ_DBG_ENTERA("ring=%d iru_pidx=%d iru_count=%d iru->iru_buf_size=%d",
|
||||
iru->iru_qsidx, iru->iru_pidx, iru->iru_count, iru->iru_buf_size);
|
||||
iru->iru_qsidx, iru->iru_pidx, iru->iru_count, iru->iru_buf_size);
|
||||
|
||||
ring = aq_dev->rx_rings[iru->iru_qsidx];
|
||||
pidx = iru->iru_pidx;
|
||||
@@ -248,8 +256,8 @@ static void aq_ring_rx_refill(void* arg, if_rxd_update_t iru)
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static void aq_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused,
|
||||
qidx_t pidx)
|
||||
static void
|
||||
aq_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, qidx_t pidx)
|
||||
{
|
||||
aq_dev_t *aq_dev = arg;
|
||||
struct aq_ring *ring = aq_dev->rx_rings[rxqid];
|
||||
@@ -259,7 +267,8 @@ static void aq_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused,
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static int aq_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget)
|
||||
static int
|
||||
aq_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget)
|
||||
{
|
||||
aq_dev_t *aq_dev = arg;
|
||||
struct aq_ring *ring = aq_dev->rx_rings[rxqid];
|
||||
@@ -268,8 +277,9 @@ static int aq_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t bu
|
||||
|
||||
AQ_DBG_ENTERA("[%d] head=%u, budget %d", ring->index, idx, budget);
|
||||
|
||||
for (iter = 0, cnt = 0, i = idx; iter < ring->rx_size && cnt <= budget;) {
|
||||
trace_aq_rx_descr(ring->index, i, (volatile u64*)&rx_desc[i]);
|
||||
for (iter = 0, cnt = 0, i = idx;
|
||||
iter < ring->rx_size && cnt <= budget;) {
|
||||
trace_aq_rx_descr(ring->index, i, (volatile uint64_t*)&rx_desc[i]);
|
||||
if (!rx_desc[i].wb.dd)
|
||||
break;
|
||||
|
||||
@@ -296,7 +306,8 @@ static int aq_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t bu
|
||||
return (cnt);
|
||||
}
|
||||
|
||||
static void aq_rx_set_cso_flags(aq_rx_desc_t *rx_desc, if_rxd_info_t ri)
|
||||
static void
|
||||
aq_rx_set_cso_flags(aq_rx_desc_t *rx_desc, if_rxd_info_t ri)
|
||||
{
|
||||
if ((rx_desc->wb.pkt_type & 0x3) == 0) { //IPv4
|
||||
if (rx_desc->wb.rx_cntl & BIT(0)){ // IPv4 csum checked
|
||||
@@ -316,17 +327,18 @@ static void aq_rx_set_cso_flags(aq_rx_desc_t *rx_desc, if_rxd_info_t ri)
|
||||
}
|
||||
|
||||
static uint8_t bsd_rss_type[16] = {
|
||||
[AQ_RX_RSS_TYPE_IPV4]=M_HASHTYPE_RSS_IPV4,
|
||||
[AQ_RX_RSS_TYPE_IPV6]=M_HASHTYPE_RSS_IPV6,
|
||||
[AQ_RX_RSS_TYPE_IPV4_TCP]=M_HASHTYPE_RSS_TCP_IPV4,
|
||||
[AQ_RX_RSS_TYPE_IPV6_TCP]=M_HASHTYPE_RSS_TCP_IPV6,
|
||||
[AQ_RX_RSS_TYPE_IPV4_UDP]=M_HASHTYPE_RSS_UDP_IPV4,
|
||||
[AQ_RX_RSS_TYPE_IPV6_UDP]=M_HASHTYPE_RSS_UDP_IPV6,
|
||||
[AQ_RX_RSS_TYPE_IPV4] = M_HASHTYPE_RSS_IPV4,
|
||||
[AQ_RX_RSS_TYPE_IPV6] = M_HASHTYPE_RSS_IPV6,
|
||||
[AQ_RX_RSS_TYPE_IPV4_TCP] = M_HASHTYPE_RSS_TCP_IPV4,
|
||||
[AQ_RX_RSS_TYPE_IPV6_TCP] = M_HASHTYPE_RSS_TCP_IPV6,
|
||||
[AQ_RX_RSS_TYPE_IPV4_UDP] = M_HASHTYPE_RSS_UDP_IPV4,
|
||||
[AQ_RX_RSS_TYPE_IPV6_UDP] = M_HASHTYPE_RSS_UDP_IPV6,
|
||||
};
|
||||
|
||||
|
||||
|
||||
static int aq_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
|
||||
static int
|
||||
aq_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
|
||||
{
|
||||
aq_dev_t *aq_dev = arg;
|
||||
struct aq_ring *ring = aq_dev->rx_rings[ri->iri_qsidx];
|
||||
@@ -343,7 +355,7 @@ static int aq_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
|
||||
do {
|
||||
rx_desc = (aq_rx_desc_t *) &ring->rx_descs[cidx];
|
||||
|
||||
trace_aq_rx_descr(ring->index, cidx, (volatile u64*)rx_desc);
|
||||
trace_aq_rx_descr(ring->index, cidx, (volatile uint64_t*)rx_desc);
|
||||
|
||||
if ((rx_desc->wb.rx_stat & BIT(0)) != 0) {
|
||||
ring->stats.rx_err++;
|
||||
@@ -393,20 +405,24 @@ static int aq_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
static void aq_setup_offloads(aq_dev_t *aq_dev, if_pkt_info_t pi, aq_tx_desc_t *txd, u32 tx_cmd)
|
||||
static void
|
||||
aq_setup_offloads(aq_dev_t *aq_dev, if_pkt_info_t pi, aq_tx_desc_t *txd,
|
||||
uint32_t tx_cmd)
|
||||
{
|
||||
AQ_DBG_ENTER();
|
||||
txd->cmd |= tx_desc_cmd_fcs;
|
||||
txd->cmd |= (pi->ipi_csum_flags & (CSUM_IP|CSUM_TSO)) ? tx_desc_cmd_ipv4 : 0;
|
||||
txd->cmd |= (pi->ipi_csum_flags &
|
||||
(CSUM_IP_TCP | CSUM_IP6_TCP | CSUM_IP_UDP | CSUM_IP6_UDP)
|
||||
) ? tx_desc_cmd_l4cs : 0;
|
||||
txd->cmd |= (pi->ipi_flags & IPI_TX_INTR) ? tx_desc_cmd_wb : 0;
|
||||
txd->cmd |= tx_cmd;
|
||||
AQ_DBG_EXIT(0);
|
||||
AQ_DBG_ENTER();
|
||||
txd->cmd |= tx_desc_cmd_fcs;
|
||||
txd->cmd |= (pi->ipi_csum_flags & (CSUM_IP|CSUM_TSO)) ?
|
||||
tx_desc_cmd_ipv4 : 0;
|
||||
txd->cmd |= (pi->ipi_csum_flags & (CSUM_IP_TCP | CSUM_IP6_TCP |
|
||||
CSUM_IP_UDP | CSUM_IP6_UDP)) ? tx_desc_cmd_l4cs : 0;
|
||||
txd->cmd |= (pi->ipi_flags & IPI_TX_INTR) ? tx_desc_cmd_wb : 0;
|
||||
txd->cmd |= tx_cmd;
|
||||
AQ_DBG_EXIT(0);
|
||||
}
|
||||
|
||||
static int aq_ring_tso_setup(aq_dev_t *aq_dev, if_pkt_info_t pi, uint32_t *hdrlen, aq_txc_desc_t *txc)
|
||||
static int
|
||||
aq_ring_tso_setup(aq_dev_t *aq_dev, if_pkt_info_t pi, uint32_t *hdrlen,
|
||||
aq_txc_desc_t *txc)
|
||||
{
|
||||
uint32_t tx_cmd = 0;
|
||||
|
||||
@@ -448,7 +464,8 @@ static int aq_ring_tso_setup(aq_dev_t *aq_dev, if_pkt_info_t pi, uint32_t *hdrle
|
||||
return (tx_cmd);
|
||||
}
|
||||
|
||||
static int aq_isc_txd_encap(void *arg, if_pkt_info_t pi)
|
||||
static int
|
||||
aq_isc_txd_encap(void *arg, if_pkt_info_t pi)
|
||||
{
|
||||
aq_dev_t *aq_dev = arg;
|
||||
struct aq_ring *ring;
|
||||
@@ -477,7 +494,8 @@ static int aq_isc_txd_encap(void *arg, if_pkt_info_t pi)
|
||||
AQ_DBG_PRINT("tx_cmd = 0x%x", tx_cmd);
|
||||
|
||||
if (tx_cmd) {
|
||||
trace_aq_tx_context_descr(ring->index, pidx, (volatile void*)txc);
|
||||
trace_aq_tx_context_descr(ring->index, pidx,
|
||||
(volatile void*)txc);
|
||||
/* We've consumed the first desc, adjust counters */
|
||||
pidx = aq_next(pidx, ring->tx_size - 1);
|
||||
|
||||
@@ -515,7 +533,8 @@ static int aq_isc_txd_encap(void *arg, if_pkt_info_t pi)
|
||||
txd->len = segs[i].ds_len;
|
||||
txd->pay_len = pay_len;
|
||||
if (i < pi->ipi_nsegs - 1)
|
||||
trace_aq_tx_descr(ring->index, pidx, (volatile void*)txd);
|
||||
trace_aq_tx_descr(ring->index, pidx,
|
||||
(volatile void*)txd);
|
||||
|
||||
pidx = aq_next(pidx, ring->tx_size - 1);
|
||||
|
||||
@@ -537,7 +556,8 @@ static int aq_isc_txd_encap(void *arg, if_pkt_info_t pi)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void aq_isc_txd_flush(void *arg, uint16_t txqid, qidx_t pidx)
|
||||
static void
|
||||
aq_isc_txd_flush(void *arg, uint16_t txqid, qidx_t pidx)
|
||||
{
|
||||
aq_dev_t *aq_dev = arg;
|
||||
struct aq_ring *ring = aq_dev->tx_rings[txqid];
|
||||
@@ -549,12 +569,14 @@ static void aq_isc_txd_flush(void *arg, uint16_t txqid, qidx_t pidx)
|
||||
}
|
||||
|
||||
|
||||
static inline unsigned int aq_avail_desc(int a, int b, int size)
|
||||
static inline unsigned int
|
||||
aq_avail_desc(int a, int b, int size)
|
||||
{
|
||||
return (((b >= a)) ? ((size ) - b + a) : (a - b));
|
||||
return (((b >= a)) ? ((size) - b + a) : (a - b));
|
||||
}
|
||||
|
||||
static int aq_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear)
|
||||
static int
|
||||
aq_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear)
|
||||
{
|
||||
aq_dev_t *aq_dev = arg;
|
||||
struct aq_ring *ring = aq_dev->tx_rings[txqid];
|
||||
@@ -567,7 +589,7 @@ static int aq_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear)
|
||||
AQ_DBG_PRINT("swhead %d hwhead %d", ring->tx_head, head);
|
||||
|
||||
if (ring->tx_head == head) {
|
||||
avail = 0; //ring->tx_size;
|
||||
avail = 0; // ring->tx_size;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
+91
-91
@@ -41,130 +41,130 @@
|
||||
|
||||
|
||||
typedef volatile struct {
|
||||
u32 rss_type:4;
|
||||
u32 pkt_type:8;
|
||||
u32 rdm_err:1;
|
||||
u32 rsvd:6;
|
||||
u32 rx_cntl:2;
|
||||
u32 sph:1;
|
||||
u32 hdr_len:10;
|
||||
u32 rss_hash;
|
||||
u16 dd:1;
|
||||
u16 eop:1;
|
||||
u16 rx_stat:4;
|
||||
u16 rx_estat:6;
|
||||
u16 rsc_cnt:4;
|
||||
u16 pkt_len;
|
||||
u16 next_desp;
|
||||
u16 vlan;
|
||||
uint32_t rss_type:4;
|
||||
uint32_t pkt_type:8;
|
||||
uint32_t rdm_err:1;
|
||||
uint32_t rsvd:6;
|
||||
uint32_t rx_cntl:2;
|
||||
uint32_t sph:1;
|
||||
uint32_t hdr_len:10;
|
||||
uint32_t rss_hash;
|
||||
uint16_t dd:1;
|
||||
uint16_t eop:1;
|
||||
uint16_t rx_stat:4;
|
||||
uint16_t rx_estat:6;
|
||||
uint16_t rsc_cnt:4;
|
||||
uint16_t pkt_len;
|
||||
uint16_t next_desp;
|
||||
uint16_t vlan;
|
||||
} __attribute__((__packed__)) aq_rx_wb_t;
|
||||
|
||||
typedef volatile struct {
|
||||
union {
|
||||
/* HW RX descriptor */
|
||||
struct __packed {
|
||||
u64 buf_addr;
|
||||
u64 hdr_addr;
|
||||
} read;
|
||||
union {
|
||||
/* HW RX descriptor */
|
||||
struct __packed {
|
||||
uint64_t buf_addr;
|
||||
uint64_t hdr_addr;
|
||||
} read;
|
||||
|
||||
/* HW RX descriptor writeback */
|
||||
aq_rx_wb_t wb;
|
||||
};
|
||||
/* HW RX descriptor writeback */
|
||||
aq_rx_wb_t wb;
|
||||
};
|
||||
} __attribute__((__packed__)) aq_rx_desc_t;
|
||||
|
||||
/* Hardware tx descriptor */
|
||||
typedef volatile struct {
|
||||
u64 buf_addr;
|
||||
uint64_t buf_addr;
|
||||
|
||||
union {
|
||||
struct {
|
||||
u32 type:3;
|
||||
u32 :1;
|
||||
u32 len:16;
|
||||
u32 dd:1;
|
||||
u32 eop:1;
|
||||
u32 cmd:8;
|
||||
u32 :14;
|
||||
u32 ct_idx:1;
|
||||
u32 ct_en:1;
|
||||
u32 pay_len:18;
|
||||
} __attribute__((__packed__));
|
||||
u64 flags;
|
||||
};
|
||||
union {
|
||||
struct {
|
||||
uint32_t type:3;
|
||||
uint32_t :1;
|
||||
uint32_t len:16;
|
||||
uint32_t dd:1;
|
||||
uint32_t eop:1;
|
||||
uint32_t cmd:8;
|
||||
uint32_t :14;
|
||||
uint32_t ct_idx:1;
|
||||
uint32_t ct_en:1;
|
||||
uint32_t pay_len:18;
|
||||
} __attribute__((__packed__));
|
||||
uint64_t flags;
|
||||
};
|
||||
} __attribute__((__packed__)) aq_tx_desc_t;
|
||||
|
||||
enum aq_tx_desc_type {
|
||||
tx_desc_type_desc = 1,
|
||||
tx_desc_type_ctx = 2,
|
||||
tx_desc_type_desc = 1,
|
||||
tx_desc_type_ctx = 2,
|
||||
};
|
||||
|
||||
enum aq_tx_desc_cmd {
|
||||
tx_desc_cmd_vlan = 1,
|
||||
tx_desc_cmd_fcs = 2,
|
||||
tx_desc_cmd_ipv4 = 4,
|
||||
tx_desc_cmd_l4cs = 8,
|
||||
tx_desc_cmd_lso = 0x10,
|
||||
tx_desc_cmd_wb = 0x20,
|
||||
tx_desc_cmd_vlan = 1,
|
||||
tx_desc_cmd_fcs = 2,
|
||||
tx_desc_cmd_ipv4 = 4,
|
||||
tx_desc_cmd_l4cs = 8,
|
||||
tx_desc_cmd_lso = 0x10,
|
||||
tx_desc_cmd_wb = 0x20,
|
||||
};
|
||||
|
||||
/* Hardware tx context descriptor */
|
||||
typedef volatile union {
|
||||
struct __packed {
|
||||
u64 flags1;
|
||||
u64 flags2;
|
||||
};
|
||||
struct __packed {
|
||||
uint64_t flags1;
|
||||
uint64_t flags2;
|
||||
};
|
||||
|
||||
struct __packed {
|
||||
u64 :40;
|
||||
u32 tun_len:8;
|
||||
u32 out_len:16;
|
||||
u32 type:3;
|
||||
u32 idx:1;
|
||||
u32 vlan_tag:16;
|
||||
u32 cmd:4;
|
||||
u32 l2_len:7;
|
||||
u32 l3_len:9;
|
||||
u32 l4_len:8;
|
||||
u32 mss_len:16;
|
||||
};
|
||||
struct __packed {
|
||||
uint64_t :40;
|
||||
uint32_t tun_len:8;
|
||||
uint32_t out_len:16;
|
||||
uint32_t type:3;
|
||||
uint32_t idx:1;
|
||||
uint32_t vlan_tag:16;
|
||||
uint32_t cmd:4;
|
||||
uint32_t l2_len:7;
|
||||
uint32_t l3_len:9;
|
||||
uint32_t l4_len:8;
|
||||
uint32_t mss_len:16;
|
||||
};
|
||||
} __attribute__((__packed__)) aq_txc_desc_t;
|
||||
|
||||
struct aq_ring_stats {
|
||||
u64 rx_pkts;
|
||||
u64 rx_bytes;
|
||||
u64 jumbo_pkts;
|
||||
u64 rx_err;
|
||||
u64 irq;
|
||||
uint64_t rx_pkts;
|
||||
uint64_t rx_bytes;
|
||||
uint64_t jumbo_pkts;
|
||||
uint64_t rx_err;
|
||||
uint64_t irq;
|
||||
|
||||
u64 tx_pkts;
|
||||
u64 tx_bytes;
|
||||
u64 tx_drops;
|
||||
u64 tx_queue_full;
|
||||
uint64_t tx_pkts;
|
||||
uint64_t tx_bytes;
|
||||
uint64_t tx_drops;
|
||||
uint64_t tx_queue_full;
|
||||
};
|
||||
|
||||
struct aq_dev;
|
||||
|
||||
struct aq_ring {
|
||||
struct aq_dev *dev;
|
||||
int index;
|
||||
struct aq_dev *dev;
|
||||
int index;
|
||||
|
||||
struct if_irq irq;
|
||||
int msix;
|
||||
struct if_irq irq;
|
||||
int msix;
|
||||
/* RX */
|
||||
qidx_t rx_size;
|
||||
int rx_max_frame_size;
|
||||
void *rx_desc_area_ptr;
|
||||
aq_rx_desc_t *rx_descs;
|
||||
uint64_t rx_descs_phys;
|
||||
qidx_t rx_size;
|
||||
int rx_max_frame_size;
|
||||
void *rx_desc_area_ptr;
|
||||
aq_rx_desc_t *rx_descs;
|
||||
uint64_t rx_descs_phys;
|
||||
|
||||
/* TX */
|
||||
int tx_head, tx_tail;
|
||||
qidx_t tx_size;
|
||||
void *tx_desc_area_ptr;
|
||||
aq_tx_desc_t *tx_descs;
|
||||
uint64_t tx_descs_phys;
|
||||
int tx_head, tx_tail;
|
||||
qidx_t tx_size;
|
||||
void *tx_desc_area_ptr;
|
||||
aq_tx_desc_t *tx_descs;
|
||||
uint64_t tx_descs_phys;
|
||||
|
||||
struct aq_ring_stats stats;
|
||||
struct aq_ring_stats stats;
|
||||
};
|
||||
|
||||
int aq_ring_rx_init(struct aq_hw *hw, struct aq_ring *ring);
|
||||
@@ -175,7 +175,7 @@ int aq_ring_tx_stop(struct aq_hw *hw, struct aq_ring *ring);
|
||||
int aq_ring_rx_start(struct aq_hw *hw, struct aq_ring *ring);
|
||||
int aq_ring_rx_stop(struct aq_hw *hw, struct aq_ring *ring);
|
||||
|
||||
int aq_ring_tx_tail_update(struct aq_hw *hw, struct aq_ring *ring, u32 tail);
|
||||
int aq_ring_tx_tail_update(struct aq_hw *hw, struct aq_ring *ring, uint32_t tail);
|
||||
|
||||
|
||||
extern struct if_txrx aq_txrx;
|
||||
|
||||
Reference in New Issue
Block a user