Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c58c35f authored by Igor Russkikh's avatar Igor Russkikh Committed by David S. Miller
Browse files

net: aquantia: Introduce firmware ops callbacks



New AQC cards will have an updated firmware with new binary interface.
This patch extracts firmware specific operations into a separate table
and prepares for the introduction of new fw 2.x and 3.x

Signed-off-by: default avatarIgor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 76c19c6c
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ struct aq_stats_s {
struct aq_hw_s {
	atomic_t flags;
	struct aq_nic_cfg_s *aq_nic_cfg;
	const struct aq_fw_ops *aq_fw_ops;
	void __iomem *mmio;
	struct aq_hw_link_status_s aq_link_status;
	struct hw_aq_atl_utils_mbox mbox;
@@ -121,7 +122,6 @@ struct aq_hw_s {

struct aq_ring_s;
struct aq_ring_param_s;
struct aq_nic_cfg_s;
struct sk_buff;

struct aq_hw_ops {
@@ -138,15 +138,8 @@ struct aq_hw_ops {
	int (*hw_ring_tx_head_update)(struct aq_hw_s *self,
				      struct aq_ring_s *aq_ring);

	int (*hw_get_mac_permanent)(struct aq_hw_s *self,
				    u8 *mac);

	int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);

	int (*hw_get_link_status)(struct aq_hw_s *self);

	int (*hw_set_link_speed)(struct aq_hw_s *self, u32 speed);

	int (*hw_reset)(struct aq_hw_s *self);

	int (*hw_init)(struct aq_hw_s *self, u8 *mac_addr);
@@ -200,8 +193,6 @@ struct aq_hw_ops {
			   const struct aq_hw_caps_s *aq_hw_caps,
			   u32 *regs_buff);

	int (*hw_update_stats)(struct aq_hw_s *self);

	struct aq_stats_s *(*hw_get_hw_stats)(struct aq_hw_s *self);

	int (*hw_get_fw_version)(struct aq_hw_s *self, u32 *fw_version);
@@ -211,4 +202,20 @@ struct aq_hw_ops {
	int (*hw_set_power)(struct aq_hw_s *self, unsigned int power_state);
};

struct aq_fw_ops {
	int (*init)(struct aq_hw_s *self);

	int (*reset)(struct aq_hw_s *self);

	int (*get_mac_permanent)(struct aq_hw_s *self, u8 *mac);

	int (*set_link_speed)(struct aq_hw_s *self, u32 speed);

	int (*set_state)(struct aq_hw_s *self, enum hal_atl_utils_fw_state_e state);

	int (*update_link_status)(struct aq_hw_s *self);

	int (*update_stats)(struct aq_hw_s *self);
};

#endif /* AQ_HW_H */
+3 −0
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ do { \
	} \
} while (0)

#define aq_pr_err(...) pr_err(AQ_CFG_DRV_NAME ": " __VA_ARGS__)
#define aq_pr_trace(...) pr_info(AQ_CFG_DRV_NAME ": " __VA_ARGS__)

struct aq_hw_s;

void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
+9 −5
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ void aq_nic_cfg_start(struct aq_nic_s *self)

static int aq_nic_update_link_status(struct aq_nic_s *self)
{
	int err = self->aq_hw_ops->hw_get_link_status(self->aq_hw);
	int err = self->aq_fw_ops->update_link_status(self->aq_hw);

	if (err)
		return err;
@@ -164,8 +164,8 @@ static void aq_nic_service_timer_cb(struct timer_list *t)
	if (err)
		goto err_exit;

	if (self->aq_hw_ops->hw_update_stats)
		self->aq_hw_ops->hw_update_stats(self->aq_hw);
	if (self->aq_fw_ops->update_stats)
		self->aq_fw_ops->update_stats(self->aq_hw);

	aq_nic_update_ndev_stats(self);

@@ -200,7 +200,11 @@ int aq_nic_ndev_register(struct aq_nic_s *self)
		goto err_exit;
	}

	err = self->aq_hw_ops->hw_get_mac_permanent(self->aq_hw,
	err = hw_atl_utils_initfw(self->aq_hw, &self->aq_fw_ops);
	if (err)
		goto err_exit;

	err = self->aq_fw_ops->get_mac_permanent(self->aq_hw,
			    self->ndev->dev_addr);
	if (err)
		goto err_exit;
@@ -799,7 +803,7 @@ int aq_nic_set_link_ksettings(struct aq_nic_s *self,
		self->aq_nic_cfg.is_autoneg = false;
	}

	err = self->aq_hw_ops->hw_set_link_speed(self->aq_hw, rate);
	err = self->aq_fw_ops->set_link_speed(self->aq_hw, rate);
	if (err < 0)
		goto err_exit;

+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ struct aq_nic_s {
	unsigned int power_state;
	u8 port;
	const struct aq_hw_ops *aq_hw_ops;
	const struct aq_fw_ops *aq_fw_ops;
	struct aq_nic_cfg_s aq_nic_cfg;
	struct timer_list service_timer;
	struct timer_list polling_timer;
+4 −19
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ static int hw_atl_a0_hw_reset(struct aq_hw_s *self)
	if (err < 0)
		goto err_exit;

	hw_atl_utils_mpi_set(self, MPI_RESET, 0x0U);
	self->aq_fw_ops->set_state(self, MPI_RESET);

	err = aq_hw_err_from_flags(self);

@@ -354,7 +354,8 @@ static int hw_atl_a0_hw_init(struct aq_hw_s *self, u8 *mac_addr)

	hw_atl_a0_hw_mac_addr_set(self, mac_addr);

	hw_atl_utils_mpi_set(self, MPI_INIT, aq_nic_cfg->link_speed_msk);
	self->aq_fw_ops->set_link_speed(self, aq_nic_cfg->link_speed_msk);
	self->aq_fw_ops->set_state(self, MPI_INIT);

	hw_atl_reg_tx_dma_debug_ctl_set(self, 0x800000b8U);
	hw_atl_reg_tx_dma_debug_ctl_set(self, 0x000000b8U);
@@ -365,7 +366,7 @@ static int hw_atl_a0_hw_init(struct aq_hw_s *self, u8 *mac_addr)

	/* Reset link status and read out initial hardware counters */
	self->aq_link_status.mbps = 0;
	hw_atl_utils_update_stats(self);
	self->aq_fw_ops->update_stats(self);

	err = aq_hw_err_from_flags(self);
	if (err < 0)
@@ -871,23 +872,8 @@ static int hw_atl_a0_hw_ring_rx_stop(struct aq_hw_s *self,
	return aq_hw_err_from_flags(self);
}

static int hw_atl_a0_hw_set_speed(struct aq_hw_s *self, u32 speed)
{
	int err = 0;

	err = hw_atl_utils_mpi_set_speed(self, speed, MPI_INIT);
	if (err < 0)
		goto err_exit;

err_exit:
	return err;
}

const struct aq_hw_ops hw_atl_ops_a0 = {
	.hw_get_mac_permanent = hw_atl_utils_get_mac_permanent,
	.hw_set_mac_address   = hw_atl_a0_hw_mac_addr_set,
	.hw_get_link_status   = hw_atl_utils_mpi_get_link_status,
	.hw_set_link_speed    = hw_atl_a0_hw_set_speed,
	.hw_init              = hw_atl_a0_hw_init,
	.hw_deinit            = hw_atl_utils_hw_deinit,
	.hw_set_power         = hw_atl_utils_hw_set_power,
@@ -917,7 +903,6 @@ const struct aq_hw_ops hw_atl_ops_a0 = {
	.hw_rss_set                  = hw_atl_a0_hw_rss_set,
	.hw_rss_hash_set             = hw_atl_a0_hw_rss_hash_set,
	.hw_get_regs                 = hw_atl_utils_hw_get_regs,
	.hw_update_stats             = hw_atl_utils_update_stats,
	.hw_get_hw_stats             = hw_atl_utils_get_hw_stats,
	.hw_get_fw_version           = hw_atl_utils_get_fw_version,
};
Loading