git: 5409e03a0ef1 - main - aq(4): modernize and de-Linuxify the vendor driver
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 20 Jun 2026 19:10:39 UTC
The branch main has been updated by adrian:
URL: https://cgit.FreeBSD.org/src/commit/?id=5409e03a0ef1f2d71da94bedd433fbaa7b6b21f2
commit 5409e03a0ef1f2d71da94bedd433fbaa7b6b21f2
Author: Nick Price <nick@spun.io>
AuthorDate: 2026-06-20 19:03:09 +0000
Commit: Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2026-06-20 19:10:16 +0000
aq(4): modernize and de-Linuxify the vendor driver
Dead-code removal, device_printf(9) logging, style(9) de-Linuxification,
const F/W-ops tables, and readability cleanups. No change for valid
traffic.
Dead code and logging:
- Remove the sub-gigabit TSO-masking block in the link-state ISR: it
cleared IFCAP_TSO from the static isc_capabilities record (read only at
attach / SIOCSIFCAP, never on the datapath), so it never gated TSO and
only corrupted the validation mask. The Atlantic has no sub-gigabit TSO
erratum.
- Tidy the RX buffer-size handling: drop the dead switch(MCLBYTES) in
aq_if_rx_queues_alloc, rename rx_max_frame_size -> rx_buf_size, and bound
the per-fragment length from the wb.pkt_len writeback (EBADMSG on
underflow or a final fragment longer than the RX buffer).
- Drop every __FreeBSD__/__FreeBSD_version branch (FreeBSD 14.0 baseline);
the pre-13 arms used pre-opaque-if_t APIs since removed and one never
built.
- Route all log messages through device_printf(9) (MAC via %6D), adding a
device_t to struct aq_hw; drop the dead AQ_XXX_UNIMPLEMENTED_FUNCTION and
aq_log_error macros and the per-ring init console spam.
- Minor: comma -> semicolon in aq_if_attach_pre; (uint64_t) -> (uint32_t)
TX high-word cast; MODULE_VERSION(atlantic, 1); remove unused/duplicate
#includes.
style(9) and types:
- Remove all typedef'd struct/enum/union types (aq_dev_t, the speed/fc/
debug enums, the volatile RX/TX descriptor types, the firmware-file
types) in favor of bare tags; for the DMA descriptors the volatile
qualifier moves to the pointer/use sites. Drop the _s/_e tag suffixes
and the "#define aq_hw_s aq_hw" alias. Rename the OOP-style *self
parameter to hw. Replace usec_delay/msec_delay/ARRAY_SIZE/LOWORD with
FreeBSD equivalents (BIT kept). __attribute__((__packed__)) -> __packed.
F/W-ops vtable:
- Rename the leftover hal parameter to hw; make aq_fw1x_ops/aq_fw2x_ops
const (read-only data); drop the always-true "fw_ops &&" and
always-present dispatch guards (only led_control, absent in F/W 1.x,
keeps its NULL check).
Readability:
- aq_isc_rxd_pkt_get: fold the four identical RX-error blocks into one
rx_err: label. aq_isc_rxd_available: hoist the shared descriptor advance
out of the EOP test and drop the redundant continue. aq_hw_offload_set:
drop the dead "int err = 0". Fix a stale "10 ms" comment on a 50 ms
DELAY and the redundant literal parentheses.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D57438
---
sys/dev/aq/aq_common.h | 12 +---
sys/dev/aq/aq_dbg.c | 2 +-
sys/dev/aq/aq_dbg.h | 11 ++--
sys/dev/aq/aq_device.h | 16 +++--
sys/dev/aq/aq_fw.c | 49 ++++++++-------
sys/dev/aq/aq_fw.h | 20 +++----
sys/dev/aq/aq_fw1x.c | 56 +++++++++---------
sys/dev/aq/aq_fw2x.c | 80 ++++++++++++-------------
sys/dev/aq/aq_hw.c | 157 ++++++++++++++++++++++---------------------------
sys/dev/aq/aq_hw.h | 42 ++++++-------
sys/dev/aq/aq_hw_llh.c | 86 +++++++++++++--------------
sys/dev/aq/aq_irq.c | 17 +-----
sys/dev/aq/aq_main.c | 104 ++++++--------------------------
sys/dev/aq/aq_media.c | 13 ++--
sys/dev/aq/aq_ring.c | 88 ++++++++++++---------------
sys/dev/aq/aq_ring.h | 26 ++++----
16 files changed, 328 insertions(+), 451 deletions(-)
diff --git a/sys/dev/aq/aq_common.h b/sys/dev/aq/aq_common.h
index 6529f249ff62..5c497d071802 100644
--- a/sys/dev/aq/aq_common.h
+++ b/sys/dev/aq/aq_common.h
@@ -40,24 +40,14 @@
#define BIT(nr) (1UL << (nr))
-#define usec_delay(x) DELAY(x)
-
-#ifndef msec_delay
-#define msec_delay(x) DELAY(x*1000)
-#define msec_delay_irq(x) DELAY(x*1000)
-#endif
-
#define AQ_HW_WAIT_FOR(_B_, _US_, _N_) ({ \
unsigned int _i; \
for (_i = (_N_); !(_B_) && _i; --_i) \
- usec_delay(_US_); \
+ DELAY(_US_); \
(_i == 0) ? ETIMEDOUT : 0; \
})
-#define LOWORD(a) ((uint16_t)(a))
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
#define AQ_VER "0.0.5"
#endif // _AQ_COMMON_H_
diff --git a/sys/dev/aq/aq_dbg.c b/sys/dev/aq/aq_dbg.c
index bed29b3d0755..ec3954185749 100644
--- a/sys/dev/aq/aq_dbg.c
+++ b/sys/dev/aq/aq_dbg.c
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$");
#include "aq_dbg.h"
-const aq_debug_level dbg_level_ = lvl_detail;
+const enum aq_debug_level dbg_level_ = lvl_detail;
const uint32_t dbg_categories_ = dbg_init | dbg_config | dbg_fw;
diff --git a/sys/dev/aq/aq_dbg.h b/sys/dev/aq/aq_dbg.h
index d90a8599e085..280572e7d5da 100644
--- a/sys/dev/aq/aq_dbg.h
+++ b/sys/dev/aq/aq_dbg.h
@@ -88,15 +88,15 @@ Debug levels:
#define AQ_DBG_DUMP_DESC(desc)
#endif
-typedef enum aq_debug_level
+enum aq_debug_level
{
lvl_error = LOG_ERR,
lvl_warn = LOG_WARNING,
lvl_trace = LOG_NOTICE,
lvl_detail = LOG_INFO,
-} aq_debug_level;
+};
-typedef enum aq_debug_category
+enum aq_debug_category
{
dbg_init = 1,
dbg_config = 1 << 1,
@@ -104,12 +104,12 @@ typedef enum aq_debug_category
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 enum aq_debug_level dbg_level_;
extern const uint32_t dbg_categories_;
#define log_base_(_lvl, _fmt, args...) printf( "atlantic: " _fmt "\n", ##args)
@@ -120,7 +120,6 @@ extern const uint32_t dbg_categories_;
#define trace_base_(_lvl, _cat, _fmt, ...) do {} while (0)
#endif // AQ_CFG_DEBUG_LVL > 0
-#define aq_log_error(_fmt, args...) log_base_(lvl_error, "[!] " _fmt, ##args)
#define aq_log_warn(_fmt, args...) log_base_(lvl_warn, "/!\\ " _fmt, ##args)
#define aq_log(_fmt, args...) log_base_(lvl_trace, _fmt, ##args)
#define aq_log_detail(_fmt, args...) log_base_(lvl_detail, _fmt, ##args)
diff --git a/sys/dev/aq/aq_device.h b/sys/dev/aq/aq_device.h
index 64edbd138b3a..23785c1854c5 100644
--- a/sys/dev/aq/aq_device.h
+++ b/sys/dev/aq/aq_device.h
@@ -53,7 +53,7 @@ enum aq_media_type {
#define AQ_LINK_ALL (AQ_LINK_100M | AQ_LINK_1G | AQ_LINK_2G5 | AQ_LINK_5G | \
AQ_LINK_10G )
-struct aq_stats_s {
+struct aq_stats {
uint64_t prc;
uint64_t uprc;
uint64_t mprc;
@@ -77,7 +77,7 @@ struct aq_stats_s {
uint64_t bbtc;
};
-enum aq_dev_state_e {
+enum aq_dev_state {
AQ_DEV_STATE_UNLOAD,
AQ_DEV_STATE_PCI_STOP,
AQ_DEV_STATE_DOWN,
@@ -126,8 +126,8 @@ struct aq_dev {
bool linkup;
int media_active;
- struct aq_hw_stats_s last_stats;
- struct aq_stats_s curr_stats;
+ struct aq_hw_stats last_stats;
+ struct aq_stats curr_stats;
bitstr_t *vlan_tags;
int mcnt;
@@ -136,13 +136,11 @@ struct aq_dev {
uint8_t rss_table[HW_ATL_RSS_INDIRECTION_TABLE_MAX];
};
-typedef struct aq_dev aq_dev_t;
-
-int aq_update_hw_stats(aq_dev_t *aq_dev);
-void aq_initmedia(aq_dev_t *aq_dev);
+int aq_update_hw_stats(struct aq_dev *aq_dev);
+void aq_initmedia(struct aq_dev *aq_dev);
int aq_linkstat_isr(void *arg);
int aq_isr_rx(void *arg);
-void aq_mediastatus_update(aq_dev_t *aq_dev, uint32_t link_speed, const struct aq_hw_fc_info *fc_neg);
+void aq_mediastatus_update(struct aq_dev *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);
diff --git a/sys/dev/aq/aq_fw.c b/sys/dev/aq/aq_fw.c
index 487137e9c61e..7f9496add875 100644
--- a/sys/dev/aq/aq_fw.c
+++ b/sys/dev/aq/aq_fw.c
@@ -48,18 +48,17 @@ __FBSDID("$FreeBSD$");
#include "aq_hw_llh_internal.h"
#include "aq_fw.h"
-#include "aq_common.h"
#include "aq_dbg.h"
-typedef enum aq_fw_bootloader_mode
+enum aq_fw_bootloader_mode
{
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
@@ -86,13 +85,13 @@ const uint32_t RBL_STATUS_HOST_BOOT = 0xf1a7;
const uint32_t SCRATCHPAD_FW_LOADER_STATUS = (0x40 / sizeof(uint32_t));
-extern struct aq_firmware_ops aq_fw1x_ops;
-extern struct aq_firmware_ops aq_fw2x_ops;
+extern const struct aq_firmware_ops aq_fw1x_ops;
+extern const struct aq_firmware_ops aq_fw2x_ops;
-int mac_soft_reset_(struct aq_hw* hw, aq_fw_bootloader_mode* mode);
+int mac_soft_reset_(struct aq_hw* hw, enum aq_fw_bootloader_mode* mode);
int mac_soft_reset_flb_(struct aq_hw* hw);
-int mac_soft_reset_rbl_(struct aq_hw* hw, aq_fw_bootloader_mode* mode);
+int mac_soft_reset_rbl_(struct aq_hw* hw, enum aq_fw_bootloader_mode* mode);
int wait_init_mac_firmware_(struct aq_hw* hw);
@@ -111,7 +110,7 @@ aq_fw_reset(struct aq_hw* hw)
}
if (k == 1000) {
- aq_log_error("Neither RBL nor FLB started");
+ device_printf(hw->dev, "Neither RBL nor FLB started\n");
return (EBUSY);
}
@@ -131,10 +130,10 @@ aq_fw_reset(struct aq_hw* hw)
return (0);
}
- aq_fw_bootloader_mode mode = boot_mode_unknown;
+ enum 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);
+ device_printf(hw->dev, "MAC reset failed: %d\n", err);
return (err);
}
@@ -150,12 +149,12 @@ aq_fw_reset(struct aq_hw* hw)
return wait_init_mac_firmware_(hw);
case boot_mode_unknown:
- aq_log_error("F/W bootload error: unknown bootloader type");
+ device_printf(hw->dev, "F/W bootload error: unknown bootloader type\n");
return (ENOTSUP);
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");
+ device_printf(hw->dev, "RBL> Host Bootload mode: this driver does not support Host Boot\n");
return (ENOTSUP);
#else
trace(dbg_init, "RBL> Host Bootload mode");
@@ -166,7 +165,7 @@ aq_fw_reset(struct aq_hw* hw)
/*
* #todo: Host Boot
*/
- aq_log_error("RBL> F/W Host Bootload not implemented");
+ device_printf(hw->dev, "RBL> F/W Host Bootload not implemented\n");
return (ENOTSUP);
}
@@ -191,14 +190,14 @@ aq_fw_ops_init(struct aq_hw* hw)
return (0);
}
- aq_log_error("aq_fw_ops_init(): invalid F/W version %#x",
+ device_printf(hw->dev, "aq_fw_ops_init(): invalid F/W version %#x\n",
hw->fw_version.raw);
return (ENOTSUP);
}
int
-mac_soft_reset_(struct aq_hw* hw, aq_fw_bootloader_mode* mode /*= nullptr*/)
+mac_soft_reset_(struct aq_hw* hw, enum aq_fw_bootloader_mode* mode /*= nullptr*/)
{
if (hw->rbl_enabled) {
return mac_soft_reset_rbl_(hw, mode);
@@ -218,7 +217,7 @@ mac_soft_reset_flb_(struct aq_hw* hw)
reg_global_ctl2_set(hw, 0x40e1);
// Let Felicity hardware complete SMBUS transaction before Global
// software reset.
- msec_delay(50);
+ DELAY((50) * 1000);
/*
* If SPI burst transaction was interrupted(before running the script),
@@ -228,7 +227,7 @@ mac_soft_reset_flb_(struct aq_hw* hw)
reg_glb_nvr_provisioning2_set(hw, 0xa0);
reg_glb_nvr_interface1_set(hw, 0x9f);
reg_glb_nvr_interface1_set(hw, 0x809f);
- msec_delay(50);
+ DELAY((50) * 1000);
reg_glb_standard_ctl1_set(hw, (reg_glb_standard_ctl1_get(hw) & ~glb_reg_res_dis_msk) | glb_soft_res_msk);
@@ -242,7 +241,7 @@ mac_soft_reset_flb_(struct aq_hw* hw)
* 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.
+ DELAY(50 * 1000);
/* MAC Kickstart */
if (!hw->fast_start_enabled) {
@@ -254,7 +253,7 @@ mac_soft_reset_flb_(struct aq_hw* hw)
flb_status = reg_glb_daisy_chain_status1_get(hw) & 0x10;
if (flb_status != 0)
break;
- msec_delay(10); // Sleep for 10 ms.
+ DELAY(10 * 1000);
}
if (flb_status == 0) {
@@ -268,7 +267,7 @@ mac_soft_reset_flb_(struct aq_hw* hw)
reg_global_ctl2_set(hw, 0x80e0);
// Let Felicity hardware complete SMBUS transaction before
// Global software reset.
- msec_delay(50);
+ DELAY((50) * 1000);
}
reg_glb_cpu_sem_set(hw, 1, 0);
@@ -285,7 +284,7 @@ mac_soft_reset_flb_(struct aq_hw* hw)
restart_completed = reg_glb_fw_image_id1_get(hw) != 0;
if (restart_completed)
break;
- msec_delay(10);
+ DELAY((10) * 1000);
}
if (!restart_completed) {
@@ -298,7 +297,7 @@ mac_soft_reset_flb_(struct aq_hw* hw)
}
int
-mac_soft_reset_rbl_(struct aq_hw* hw, aq_fw_bootloader_mode* mode)
+mac_soft_reset_rbl_(struct aq_hw* hw, enum aq_fw_bootloader_mode* mode)
{
trace(dbg_init, "RBL> MAC reset STARTED!");
@@ -322,11 +321,11 @@ mac_soft_reset_rbl_(struct aq_hw* hw, aq_fw_bootloader_mode* mode)
// 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));
+ rbl_status = ((uint16_t)(reg_glb_cpu_no_reset_scratchpad_get(hw, NO_RESET_SCRATCHPAD_RBL_STATUS)));
if (rbl_status != 0 && rbl_status != 0xDEAD)
break;
- msec_delay(1);
+ DELAY((1) * 1000);
}
if (rbl_status == 0 || rbl_status == 0xDEAD) {
@@ -357,7 +356,7 @@ wait_init_mac_firmware_(struct aq_hw* hw)
if ((hw->fw_version.raw = AQ_READ_REG(hw, 0x18)) != 0)
return (0);
- msec_delay(1);
+ DELAY((1) * 1000);
}
trace_error(dbg_init,
diff --git a/sys/dev/aq/aq_fw.h b/sys/dev/aq/aq_fw.h
index ea2c37b6c92c..9195c91d6b5f 100644
--- a/sys/dev/aq/aq_fw.h
+++ b/sys/dev/aq/aq_fw.h
@@ -36,7 +36,7 @@
struct aq_hw;
-typedef enum aq_fw_link_speed
+enum aq_fw_link_speed
{
aq_fw_none = 0,
aq_fw_100M = (1 << 0),
@@ -44,30 +44,30 @@ typedef enum aq_fw_link_speed
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
+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_link_fc_t;
+};
#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* hw);
- 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* hw, enum aq_hw_fw_mpi_state mode, enum aq_fw_link_speed speed);
+ int (*get_mode)(struct aq_hw* hw, enum aq_hw_fw_mpi_state* mode, enum aq_fw_link_speed* speed, enum aq_fw_link_fc* fc);
- 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 (*get_mac_addr)(struct aq_hw* hw, uint8_t* mac_addr);
+ int (*get_stats)(struct aq_hw* hw, struct aq_hw_stats* stats);
- int (*led_control)(struct aq_hw* hal, uint32_t mode);
+ int (*led_control)(struct aq_hw* hw, uint32_t mode);
};
diff --git a/sys/dev/aq/aq_fw1x.c b/sys/dev/aq/aq_fw1x.c
index f5458b174c3f..731370e94f3e 100644
--- a/sys/dev/aq/aq_fw1x.c
+++ b/sys/dev/aq/aq_fw1x.c
@@ -49,14 +49,14 @@ __FBSDID("$FreeBSD$");
#define FW1X_MPI_STATE_ADR 0x36C
-typedef enum fw1x_mode {
+enum fw1x_mode {
FW1X_MPI_DEINIT = 0,
FW1X_MPI_RESERVED = 1,
FW1X_MPI_INIT = 2,
FW1X_MPI_POWER = 4,
-} fw1x_mode;
+};
-typedef enum aq_fw1x_rate {
+enum aq_fw1x_rate {
FW1X_RATE_10G = 1 << 0,
FW1X_RATE_5G = 1 << 1,
FW1X_RATE_5GSR = 1 << 2,
@@ -64,9 +64,9 @@ typedef enum aq_fw1x_rate {
FW1X_RATE_1G = 1 << 4,
FW1X_RATE_100M = 1 << 5,
FW1X_RATE_INVALID = 1 << 6,
-} aq_fw1x_rate;
+};
-typedef union fw1x_state_reg {
+union fw1x_state_reg {
uint32_t val;
struct {
uint8_t mode;
@@ -77,20 +77,20 @@ typedef union fw1x_state_reg {
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_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state mode,
+ enum aq_fw_link_speed speed);
+int fw1x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state* mode,
+ enum aq_fw_link_speed* speed, enum aq_fw_link_fc* 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);
+int fw1x_get_stats(struct aq_hw* hw, struct aq_hw_stats* stats);
-static fw1x_mode
-mpi_mode_to_fw1x_(enum aq_hw_fw_mpi_state_e mode)
+static enum fw1x_mode
+mpi_mode_to_fw1x_(enum aq_hw_fw_mpi_state mode)
{
switch (mode) {
case MPI_DEINIT:
@@ -113,7 +113,7 @@ mpi_mode_to_fw1x_(enum aq_hw_fw_mpi_state_e mode)
return (FW1X_MPI_RESERVED);
}
-static aq_fw1x_rate
+static enum aq_fw1x_rate
link_speed_mask_to_fw1x_(uint32_t /*aq_fw_link_speed*/ speed)
{
uint32_t rate = 0;
@@ -134,11 +134,11 @@ link_speed_mask_to_fw1x_(uint32_t /*aq_fw_link_speed*/ speed)
if (speed & aq_fw_100M)
rate |= FW1X_RATE_100M;
- return ((aq_fw1x_rate)rate);
+ return ((enum aq_fw1x_rate)rate);
}
-static aq_fw_link_speed_t
-fw1x_rate_to_link_speed_(aq_fw1x_rate rate)
+static enum aq_fw_link_speed
+fw1x_rate_to_link_speed_(enum aq_fw1x_rate rate)
{
switch (rate) {
case FW1X_RATE_10G:
@@ -164,7 +164,7 @@ fw1x_rate_to_link_speed_(aq_fw1x_rate rate)
}
int
-fw1x_reset(struct aq_hw* hal)
+fw1x_reset(struct aq_hw* hw)
{
uint32_t tid0 = ~0u; /*< Initial value of MBOX transactionId. */
struct aq_hw_fw_mbox mbox;
@@ -173,7 +173,7 @@ fw1x_reset(struct aq_hw* hal)
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,
+ aq_hw_fw_downld_dwords(hw, hw->mbox_addr, (uint32_t*)&mbox,
(uint32_t)((char*)&mbox.stats - (char*)&mbox) / sizeof(uint32_t));
// Successfully read the stats.
@@ -193,7 +193,7 @@ fw1x_reset(struct aq_hw* hal)
* Transaction ID value haven't changed since last time.
* Try reading the stats again.
*/
- usec_delay(10);
+ DELAY(10);
}
trace_error(dbg_init, "F/W 1.x reset finalize timeout");
@@ -201,8 +201,8 @@ fw1x_reset(struct aq_hw* hal)
}
int
-fw1x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode,
- aq_fw_link_speed_t speed)
+fw1x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state mode,
+ enum aq_fw_link_speed speed)
{
union fw1x_state_reg state = {0};
state.mode = mpi_mode_to_fw1x_(mode);
@@ -217,15 +217,15 @@ fw1x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode,
}
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)
+fw1x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state* mode,
+ enum aq_fw_link_speed* speed, enum aq_fw_link_fc* fc)
{
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));
- enum aq_hw_fw_mpi_state_e md = MPI_DEINIT;
+ enum aq_hw_fw_mpi_state md = MPI_DEINIT;
switch (state.mode) {
case FW1X_MPI_DEINIT:
@@ -271,7 +271,7 @@ fw1x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
}
err = aq_hw_fw_downld_dwords(hw, efuse_shadow_addr + (40 * 4),
- mac_addr, ARRAY_SIZE(mac_addr));
+ mac_addr, nitems(mac_addr));
if (err != 0) {
mac_addr[0] = 0;
mac_addr[1] = 0;
@@ -292,7 +292,7 @@ fw1x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
}
int
-fw1x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
+fw1x_get_stats(struct aq_hw* hw, struct aq_hw_stats* stats)
{
int err = 0;
@@ -311,7 +311,7 @@ fw1x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
return (err);
}
-struct aq_firmware_ops aq_fw1x_ops =
+const struct aq_firmware_ops aq_fw1x_ops =
{
.reset = fw1x_reset,
diff --git a/sys/dev/aq/aq_fw2x.c b/sys/dev/aq/aq_fw2x.c
index 0a6d433a48fc..04935e9368d4 100644
--- a/sys/dev/aq/aq_fw2x.c
+++ b/sys/dev/aq/aq_fw2x.c
@@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
#include "aq_dbg.h"
-typedef enum {
+enum fw2x_caps_lo {
CAPS_LO_10BASET_HD = 0x00,
CAPS_LO_10BASET_FD,
CAPS_LO_100BASETX_HD,
@@ -64,9 +64,9 @@ typedef enum {
CAPS_LO_2P5GBASET_FD,
CAPS_LO_5GBASET_FD,
CAPS_LO_10GBASET_FD,
-} fw2x_caps_lo;
+};
-typedef enum {
+enum fw2x_caps_hi {
CAPS_HI_RESERVED1 = 0x00,
CAPS_HI_10BASET_EEE,
CAPS_HI_RESERVED2,
@@ -99,19 +99,19 @@ typedef enum {
CAPS_HI_WOL_TIMER,
CAPS_HI_STATISTICS,
CAPS_HI_TRANSACTION_ID,
-} fw2x_caps_hi;
+};
-typedef enum aq_fw2x_rate
+enum aq_fw2x_rate
{
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
+struct fw2x_msm_statistics
{
uint32_t uprc;
uint32_t mprc;
@@ -129,36 +129,36 @@ typedef struct fw2x_msm_statistics
uint32_t ubtc;
uint32_t ptc;
uint32_t prc;
-} fw2x_msm_statistics;
+};
-typedef struct fw2x_phy_cable_diag_data
+struct fw2x_phy_cable_diag_data
{
uint32_t lane_data[4];
-} fw2x_phy_cable_diag_data;
+};
-typedef struct fw2x_capabilities {
+struct fw2x_capabilities {
uint32_t caps_lo;
uint32_t caps_hi;
-} fw2x_capabilities;
+};
-typedef struct fw2x_mailbox // struct fwHostInterface
+struct fw2x_mailbox // struct fwHostInterface
{
uint32_t version;
uint32_t transaction_id;
int32_t error;
- fw2x_msm_statistics msm; // msmStatistics_t msm;
+ struct 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;
+ struct fw2x_phy_cable_diag_data diag_data;
uint32_t reserved[8];
- fw2x_capabilities caps;
+ struct fw2x_capabilities caps;
/* ... */
-} fw2x_mailbox;
+};
// EEE caps
@@ -195,13 +195,13 @@ typedef struct fw2x_mailbox // struct fwHostInterface
// Firmware v2-3.x specific functions.
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 mode,
+ enum aq_fw_link_speed speed);
+int fw2x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state* mode,
+ enum aq_fw_link_speed* speed, enum aq_fw_link_fc* fc);
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);
+int fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats* stats);
static uint64_t
@@ -242,10 +242,10 @@ set_mpi_ctrl_(struct aq_hw* hw, uint64_t value)
int
fw2x_reset(struct aq_hw* hw)
{
- fw2x_capabilities caps = {0};
+ struct fw2x_capabilities caps = {0};
AQ_DBG_ENTER();
int err = aq_hw_fw_downld_dwords(hw,
- hw->mbox_addr + offsetof(fw2x_mailbox, caps),
+ hw->mbox_addr + offsetof(struct fw2x_mailbox, caps),
(uint32_t*)&caps, sizeof caps/sizeof(uint32_t));
if (err == 0) {
hw->fw_caps = caps.caps_lo | ((uint64_t)caps.caps_hi << 32);
@@ -262,7 +262,7 @@ fw2x_reset(struct aq_hw* hw)
}
-static aq_fw2x_rate
+static enum aq_fw2x_rate
link_speed_mask_to_fw2x_(uint32_t speed)
{
uint32_t rate = 0;
@@ -284,13 +284,13 @@ link_speed_mask_to_fw2x_(uint32_t speed)
rate |= FW2X_RATE_100M;
AQ_DBG_EXIT(rate);
- return ((aq_fw2x_rate)rate);
+ return ((enum 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)
+fw2x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state mode,
+ enum aq_fw_link_speed speed)
{
uint64_t mpi_ctrl = get_mpi_ctrl_(hw);
@@ -326,8 +326,8 @@ fw2x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode,
}
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)
+fw2x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state* mode,
+ enum aq_fw_link_speed* link_speed, enum aq_fw_link_fc* fc)
{
uint64_t mpi_state = get_mpi_state_(hw);
uint32_t rates = mpi_state & FW2X_RATE_MASK;
@@ -342,7 +342,7 @@ fw2x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode,
*mode = MPI_DEINIT;
}
- aq_fw_link_speed_t speed = aq_fw_none;
+ enum aq_fw_link_speed speed = aq_fw_none;
if (rates & FW2X_RATE_10G)
speed = aq_fw_10G;
@@ -382,7 +382,7 @@ fw2x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
}
err = aq_hw_fw_downld_dwords(hw, efuse_shadow_addr + (40 * 4), mac_addr,
- ARRAY_SIZE(mac_addr));
+ nitems(mac_addr));
if (err != 0) {
mac_addr[0] = 0;
mac_addr[1] = 0;
@@ -400,8 +400,8 @@ fw2x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
}
static inline void
-fw2x_stats_to_fw_stats_(struct aq_hw_stats_s* dst,
- const fw2x_msm_statistics* src)
+fw2x_stats_to_fw_stats_(struct aq_hw_stats* dst,
+ const struct fw2x_msm_statistics* src)
{
dst->uprc = src->uprc;
dst->mprc = src->mprc;
@@ -454,7 +454,7 @@ toggle_mpi_ctrl_and_wait_(struct aq_hw* hw, uint64_t mask, uint32_t timeout_ms,
// AQ_DBG_EXIT(true);
return (true);
}
- msec_delay(timeout_ms);
+ DELAY((timeout_ms) * 1000);
}
trace_detail(dbg_fw,
@@ -466,10 +466,10 @@ toggle_mpi_ctrl_and_wait_(struct aq_hw* hw, uint64_t mask, uint32_t timeout_ms,
int
-fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
+fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats* stats)
{
int err = 0;
- fw2x_msm_statistics fw2x_stats = {0};
+ struct fw2x_msm_statistics fw2x_stats = {0};
// AQ_DBG_ENTER();
@@ -486,7 +486,7 @@ fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
}
err = aq_hw_fw_downld_dwords(hw,
- hw->mbox_addr + offsetof(fw2x_mailbox, msm),
+ hw->mbox_addr + offsetof(struct fw2x_mailbox, msm),
(uint32_t*)&fw2x_stats, sizeof fw2x_stats/sizeof(uint32_t));
fw2x_stats_to_fw_stats_(stats, &fw2x_stats);
@@ -506,7 +506,7 @@ fw2x_led_control(struct aq_hw* hw, uint32_t onoff)
AQ_DBG_ENTER();
- aq_hw_fw_version ver_expected = { .raw = FW2X_FW_MIN_VER_LED};
+ struct 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)):
@@ -516,7 +516,7 @@ fw2x_led_control(struct aq_hw* hw, uint32_t onoff)
return (err);
}
-struct aq_firmware_ops aq_fw2x_ops =
+const struct aq_firmware_ops aq_fw2x_ops =
{
.reset = fw2x_reset,
diff --git a/sys/dev/aq/aq_hw.c b/sys/dev/aq/aq_hw.c
index 882fdf1807f2..da07c876b959 100644
--- a/sys/dev/aq/aq_hw.c
+++ b/sys/dev/aq/aq_hw.c
@@ -37,7 +37,6 @@
#include <sys/endian.h>
#include <sys/socket.h>
#include <machine/cpu.h>
-#include <net/if.h>
#include "aq_hw.h"
#include "aq_dbg.h"
@@ -133,8 +132,8 @@ err_exit:
}
int
-aq_hw_ver_match(const aq_hw_fw_version* ver_expected,
- const aq_hw_fw_version* ver_actual)
+aq_hw_ver_match(const struct aq_hw_fw_version* ver_expected,
+ const struct aq_hw_fw_version* ver_actual)
{
AQ_DBG_ENTER();
@@ -155,14 +154,14 @@ aq_hw_init_ucp(struct aq_hw *hw)
err = aq_fw_reset(hw);
if (err != 0) {
- aq_log_error("aq_hw_init_ucp(): F/W reset failed, err %d", err);
+ device_printf(hw->dev, "aq_hw_init_ucp(): F/W reset failed, err %d\n", err);
return (err);
}
aq_hw_chip_features_init(hw, &hw->chip_features);
err = aq_fw_ops_init(hw);
if (err != 0) {
- aq_log_error("could not initialize F/W ops, err %d", err);
+ device_printf(hw->dev, "could not initialize F/W ops, err %d\n", err);
return (err);
}
@@ -183,9 +182,9 @@ aq_hw_init_ucp(struct aq_hw *hw)
/* check 10 times by 1ms */
err = AQ_HW_WAIT_FOR((hw->mbox_addr = AQ_READ_REG(hw, 0x360)) != 0, 400U, 20);
- aq_hw_fw_version ver_expected = { .raw = AQ_CFG_FW_MIN_VER_EXPECTED };
+ struct aq_hw_fw_version ver_expected = { .raw = AQ_CFG_FW_MIN_VER_EXPECTED };
if (!aq_hw_ver_match(&ver_expected, &hw->fw_version))
- aq_log_error("atlantic: aq_hw_init_ucp(), wrong FW version: expected:%x actual:%x",
+ device_printf(hw->dev, "aq_hw_init_ucp(), wrong FW version: expected:%x actual:%x\n",
AQ_CFG_FW_MIN_VER_EXPECTED, hw->fw_version.raw);
AQ_DBG_EXIT(err);
@@ -210,15 +209,10 @@ err_exit:
int
aq_hw_mpi_read_stats(struct aq_hw *hw, struct aq_hw_fw_mbox *pmbox)
{
- int err = 0;
+ int err;
// AQ_DBG_ENTER();
- if (hw->fw_ops && hw->fw_ops->get_stats) {
- err = hw->fw_ops->get_stats(hw, &pmbox->stats);
- } else {
- err = ENOTSUP;
- aq_log_error("get_stats() not supported by F/W");
- }
+ err = hw->fw_ops->get_stats(hw, &pmbox->stats);
if (err == 0) {
pmbox->stats.dpc = reg_rx_dma_stat_counter7get(hw);
@@ -230,16 +224,12 @@ aq_hw_mpi_read_stats(struct aq_hw *hw, struct aq_hw_fw_mbox *pmbox)
}
static int
-aq_hw_mpi_set(struct aq_hw *hw, enum aq_hw_fw_mpi_state_e state, uint32_t speed)
+aq_hw_mpi_set(struct aq_hw *hw, enum aq_hw_fw_mpi_state state, uint32_t speed)
{
- int err = ENOTSUP;
+ int err;
AQ_DBG_ENTERA("speed %d", speed);
- if (hw->fw_ops && hw->fw_ops->set_mode) {
- err = hw->fw_ops->set_mode(hw, state, speed);
- } else {
- aq_log_error("set_mode() not supported by F/W");
- }
+ err = hw->fw_ops->set_mode(hw, state, speed);
AQ_DBG_EXIT(err);
return (err);
@@ -258,20 +248,14 @@ aq_hw_get_link_state(struct aq_hw *hw, uint32_t *link_speed, struct aq_hw_fc_inf
// AQ_DBG_ENTER();
- enum aq_hw_fw_mpi_state_e mode;
- aq_fw_link_speed_t speed = aq_fw_none;
- aq_fw_link_fc_t fc;
+ enum aq_hw_fw_mpi_state mode;
+ enum aq_fw_link_speed speed = aq_fw_none;
+ enum aq_fw_link_fc fc;
- if (hw->fw_ops && hw->fw_ops->get_mode) {
- err = hw->fw_ops->get_mode(hw, &mode, &speed, &fc);
- } else {
- aq_log_error("get_mode() not supported by F/W");
- AQ_DBG_EXIT(ENOTSUP);
- return (ENOTSUP);
- }
+ err = hw->fw_ops->get_mode(hw, &mode, &speed, &fc);
*** 1502 LINES SKIPPED ***