|
@@ -16,11 +16,13 @@
|
|
|
#include "../aq_pci_func.h"
|
|
|
#include "../aq_ring.h"
|
|
|
#include "../aq_vec.h"
|
|
|
+#include "../aq_nic.h"
|
|
|
#include "hw_atl_utils.h"
|
|
|
#include "hw_atl_llh.h"
|
|
|
|
|
|
#define HW_ATL_FW2X_MPI_EFUSE_ADDR 0x364
|
|
|
#define HW_ATL_FW2X_MPI_MBOX_ADDR 0x360
|
|
|
+#define HW_ATL_FW2X_MPI_RPC_ADDR 0x334
|
|
|
|
|
|
#define HW_ATL_FW2X_MPI_CONTROL_ADDR 0x368
|
|
|
#define HW_ATL_FW2X_MPI_CONTROL2_ADDR 0x36C
|
|
@@ -28,6 +30,42 @@
|
|
|
#define HW_ATL_FW2X_MPI_STATE_ADDR 0x370
|
|
|
#define HW_ATL_FW2X_MPI_STATE2_ADDR 0x374
|
|
|
|
|
|
+#define HW_ATL_FW2X_CAP_SLEEP_PROXY BIT(CAPS_HI_SLEEP_PROXY)
|
|
|
+#define HW_ATL_FW2X_CAP_WOL BIT(CAPS_HI_WOL)
|
|
|
+
|
|
|
+#define HW_ATL_FW2X_CTRL_SLEEP_PROXY BIT(CTRL_SLEEP_PROXY)
|
|
|
+#define HW_ATL_FW2X_CTRL_WOL BIT(CTRL_WOL)
|
|
|
+#define HW_ATL_FW2X_CTRL_LINK_DROP BIT(CTRL_LINK_DROP)
|
|
|
+#define HW_ATL_FW2X_CTRL_PAUSE BIT(CTRL_PAUSE)
|
|
|
+#define HW_ATL_FW2X_CTRL_ASYMMETRIC_PAUSE BIT(CTRL_ASYMMETRIC_PAUSE)
|
|
|
+#define HW_ATL_FW2X_CTRL_FORCE_RECONNECT BIT(CTRL_FORCE_RECONNECT)
|
|
|
+
|
|
|
+#define HW_ATL_FW2X_CAP_EEE_1G_MASK BIT(CAPS_HI_1000BASET_FD_EEE)
|
|
|
+#define HW_ATL_FW2X_CAP_EEE_2G5_MASK BIT(CAPS_HI_2P5GBASET_FD_EEE)
|
|
|
+#define HW_ATL_FW2X_CAP_EEE_5G_MASK BIT(CAPS_HI_5GBASET_FD_EEE)
|
|
|
+#define HW_ATL_FW2X_CAP_EEE_10G_MASK BIT(CAPS_HI_10GBASET_FD_EEE)
|
|
|
+
|
|
|
+#define HAL_ATLANTIC_WOL_FILTERS_COUNT 8
|
|
|
+#define HAL_ATLANTIC_UTILS_FW2X_MSG_WOL 0x0E
|
|
|
+
|
|
|
+struct __packed fw2x_msg_wol_pattern {
|
|
|
+ u8 mask[16];
|
|
|
+ u32 crc;
|
|
|
+};
|
|
|
+
|
|
|
+struct __packed fw2x_msg_wol {
|
|
|
+ u32 msg_id;
|
|
|
+ u8 hw_addr[ETH_ALEN];
|
|
|
+ u8 magic_packet_enabled;
|
|
|
+ u8 filter_count;
|
|
|
+ struct fw2x_msg_wol_pattern filter[HAL_ATLANTIC_WOL_FILTERS_COUNT];
|
|
|
+ u8 link_up_enabled;
|
|
|
+ u8 link_down_enabled;
|
|
|
+ u16 reserved;
|
|
|
+ u32 link_up_timeout;
|
|
|
+ u32 link_down_timeout;
|
|
|
+};
|
|
|
+
|
|
|
static int aq_fw2x_set_link_speed(struct aq_hw_s *self, u32 speed);
|
|
|
static int aq_fw2x_set_state(struct aq_hw_s *self,
|
|
|
enum hal_atl_utils_fw_state_e state);
|
|
@@ -38,8 +76,12 @@ static int aq_fw2x_init(struct aq_hw_s *self)
|
|
|
|
|
|
/* check 10 times by 1ms */
|
|
|
AQ_HW_WAIT_FOR(0U != (self->mbox_addr =
|
|
|
- aq_hw_read_reg(self, HW_ATL_FW2X_MPI_MBOX_ADDR)),
|
|
|
+ aq_hw_read_reg(self, HW_ATL_FW2X_MPI_MBOX_ADDR)),
|
|
|
1000U, 10U);
|
|
|
+ AQ_HW_WAIT_FOR(0U != (self->rpc_addr =
|
|
|
+ aq_hw_read_reg(self, HW_ATL_FW2X_MPI_RPC_ADDR)),
|
|
|
+ 1000U, 100U);
|
|
|
+
|
|
|
return err;
|
|
|
}
|
|
|
|
|
@@ -78,6 +120,38 @@ static enum hw_atl_fw2x_rate link_speed_mask_2fw2x_ratemask(u32 speed)
|
|
|
return rate;
|
|
|
}
|
|
|
|
|
|
+static u32 fw2x_to_eee_mask(u32 speed)
|
|
|
+{
|
|
|
+ u32 rate = 0;
|
|
|
+
|
|
|
+ if (speed & HW_ATL_FW2X_CAP_EEE_10G_MASK)
|
|
|
+ rate |= AQ_NIC_RATE_EEE_10G;
|
|
|
+ if (speed & HW_ATL_FW2X_CAP_EEE_5G_MASK)
|
|
|
+ rate |= AQ_NIC_RATE_EEE_5G;
|
|
|
+ if (speed & HW_ATL_FW2X_CAP_EEE_2G5_MASK)
|
|
|
+ rate |= AQ_NIC_RATE_EEE_2GS;
|
|
|
+ if (speed & HW_ATL_FW2X_CAP_EEE_1G_MASK)
|
|
|
+ rate |= AQ_NIC_RATE_EEE_1G;
|
|
|
+
|
|
|
+ return rate;
|
|
|
+}
|
|
|
+
|
|
|
+static u32 eee_mask_to_fw2x(u32 speed)
|
|
|
+{
|
|
|
+ u32 rate = 0;
|
|
|
+
|
|
|
+ if (speed & AQ_NIC_RATE_EEE_10G)
|
|
|
+ rate |= HW_ATL_FW2X_CAP_EEE_10G_MASK;
|
|
|
+ if (speed & AQ_NIC_RATE_EEE_5G)
|
|
|
+ rate |= HW_ATL_FW2X_CAP_EEE_5G_MASK;
|
|
|
+ if (speed & AQ_NIC_RATE_EEE_2GS)
|
|
|
+ rate |= HW_ATL_FW2X_CAP_EEE_2G5_MASK;
|
|
|
+ if (speed & AQ_NIC_RATE_EEE_1G)
|
|
|
+ rate |= HW_ATL_FW2X_CAP_EEE_1G_MASK;
|
|
|
+
|
|
|
+ return rate;
|
|
|
+}
|
|
|
+
|
|
|
static int aq_fw2x_set_link_speed(struct aq_hw_s *self, u32 speed)
|
|
|
{
|
|
|
u32 val = link_speed_mask_2fw2x_ratemask(speed);
|
|
@@ -100,14 +174,27 @@ static void aq_fw2x_set_mpi_flow_control(struct aq_hw_s *self, u32 *mpi_state)
|
|
|
*mpi_state &= ~BIT(CAPS_HI_ASYMMETRIC_PAUSE);
|
|
|
}
|
|
|
|
|
|
+static void aq_fw2x_upd_eee_rate_bits(struct aq_hw_s *self, u32 *mpi_opts,
|
|
|
+ u32 eee_speeds)
|
|
|
+{
|
|
|
+ *mpi_opts &= ~(HW_ATL_FW2X_CAP_EEE_1G_MASK |
|
|
|
+ HW_ATL_FW2X_CAP_EEE_2G5_MASK |
|
|
|
+ HW_ATL_FW2X_CAP_EEE_5G_MASK |
|
|
|
+ HW_ATL_FW2X_CAP_EEE_10G_MASK);
|
|
|
+
|
|
|
+ *mpi_opts |= eee_mask_to_fw2x(eee_speeds);
|
|
|
+}
|
|
|
+
|
|
|
static int aq_fw2x_set_state(struct aq_hw_s *self,
|
|
|
enum hal_atl_utils_fw_state_e state)
|
|
|
{
|
|
|
u32 mpi_state = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR);
|
|
|
+ struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;
|
|
|
|
|
|
switch (state) {
|
|
|
case MPI_INIT:
|
|
|
mpi_state &= ~BIT(CAPS_HI_LINK_DROP);
|
|
|
+ aq_fw2x_upd_eee_rate_bits(self, &mpi_state, cfg->eee_speeds);
|
|
|
aq_fw2x_set_mpi_flow_control(self, &mpi_state);
|
|
|
break;
|
|
|
case MPI_DEINIT:
|
|
@@ -126,7 +213,7 @@ static int aq_fw2x_update_link_status(struct aq_hw_s *self)
|
|
|
{
|
|
|
u32 mpi_state = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE_ADDR);
|
|
|
u32 speed = mpi_state & (FW2X_RATE_100M | FW2X_RATE_1G |
|
|
|
- FW2X_RATE_2G5 | FW2X_RATE_5G | FW2X_RATE_10G);
|
|
|
+ FW2X_RATE_2G5 | FW2X_RATE_5G | FW2X_RATE_10G);
|
|
|
struct aq_hw_link_status_s *link_status = &self->aq_link_status;
|
|
|
|
|
|
if (speed) {
|
|
@@ -175,9 +262,7 @@ static int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
|
|
|
|
|
|
get_random_bytes(&rnd, sizeof(unsigned int));
|
|
|
|
|
|
- l = 0xE3000000U
|
|
|
- | (0xFFFFU & rnd)
|
|
|
- | (0x00 << 16);
|
|
|
+ l = 0xE3000000U | (0xFFFFU & rnd) | (0x00 << 16);
|
|
|
h = 0x8001300EU;
|
|
|
|
|
|
mac[5] = (u8)(0xFFU & l);
|
|
@@ -194,7 +279,7 @@ static int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static int aq_fw2x_update_stats(struct aq_hw_s *self)
|
|
|
+int aq_fw2x_update_stats(struct aq_hw_s *self)
|
|
|
{
|
|
|
int err = 0;
|
|
|
u32 mpi_opts = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR);
|
|
@@ -207,7 +292,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
|
|
|
/* Wait FW to report back */
|
|
|
AQ_HW_WAIT_FOR(orig_stats_val !=
|
|
|
(aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE2_ADDR) &
|
|
|
- BIT(CAPS_HI_STATISTICS)),
|
|
|
+ BIT(CAPS_HI_STATISTICS)),
|
|
|
1U, 10000U);
|
|
|
if (err)
|
|
|
return err;
|
|
@@ -215,6 +300,135 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
|
|
|
return hw_atl_utils_update_stats(self);
|
|
|
}
|
|
|
|
|
|
+static int aq_fw2x_set_sleep_proxy(struct aq_hw_s *self, u8 *mac)
|
|
|
+{
|
|
|
+ struct hw_atl_utils_fw_rpc *rpc = NULL;
|
|
|
+ struct offload_info *cfg = NULL;
|
|
|
+ unsigned int rpc_size = 0U;
|
|
|
+ u32 mpi_opts;
|
|
|
+ int err = 0;
|
|
|
+
|
|
|
+ rpc_size = sizeof(rpc->msg_id) + sizeof(*cfg);
|
|
|
+
|
|
|
+ err = hw_atl_utils_fw_rpc_wait(self, &rpc);
|
|
|
+ if (err < 0)
|
|
|
+ goto err_exit;
|
|
|
+
|
|
|
+ memset(rpc, 0, rpc_size);
|
|
|
+ cfg = (struct offload_info *)(&rpc->msg_id + 1);
|
|
|
+
|
|
|
+ memcpy(cfg->mac_addr, mac, ETH_ALEN);
|
|
|
+ cfg->len = sizeof(*cfg);
|
|
|
+
|
|
|
+ /* Clear bit 0x36C.23 and 0x36C.22 */
|
|
|
+ mpi_opts = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR);
|
|
|
+ mpi_opts &= ~HW_ATL_FW2X_CTRL_SLEEP_PROXY;
|
|
|
+ mpi_opts &= ~HW_ATL_FW2X_CTRL_LINK_DROP;
|
|
|
+
|
|
|
+ aq_hw_write_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR, mpi_opts);
|
|
|
+
|
|
|
+ err = hw_atl_utils_fw_rpc_call(self, rpc_size);
|
|
|
+ if (err < 0)
|
|
|
+ goto err_exit;
|
|
|
+
|
|
|
+ /* Set bit 0x36C.23 */
|
|
|
+ mpi_opts |= HW_ATL_FW2X_CTRL_SLEEP_PROXY;
|
|
|
+ aq_hw_write_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR, mpi_opts);
|
|
|
+
|
|
|
+ AQ_HW_WAIT_FOR((aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE2_ADDR) &
|
|
|
+ HW_ATL_FW2X_CTRL_SLEEP_PROXY), 1U, 10000U);
|
|
|
+
|
|
|
+err_exit:
|
|
|
+ return err;
|
|
|
+}
|
|
|
+
|
|
|
+static int aq_fw2x_set_wol_params(struct aq_hw_s *self, u8 *mac)
|
|
|
+{
|
|
|
+ struct hw_atl_utils_fw_rpc *rpc = NULL;
|
|
|
+ struct fw2x_msg_wol *msg = NULL;
|
|
|
+ u32 mpi_opts;
|
|
|
+ int err = 0;
|
|
|
+
|
|
|
+ err = hw_atl_utils_fw_rpc_wait(self, &rpc);
|
|
|
+ if (err < 0)
|
|
|
+ goto err_exit;
|
|
|
+
|
|
|
+ msg = (struct fw2x_msg_wol *)rpc;
|
|
|
+
|
|
|
+ msg->msg_id = HAL_ATLANTIC_UTILS_FW2X_MSG_WOL;
|
|
|
+ msg->magic_packet_enabled = true;
|
|
|
+ memcpy(msg->hw_addr, mac, ETH_ALEN);
|
|
|
+
|
|
|
+ mpi_opts = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR);
|
|
|
+ mpi_opts &= ~(HW_ATL_FW2X_CTRL_SLEEP_PROXY | HW_ATL_FW2X_CTRL_WOL);
|
|
|
+
|
|
|
+ aq_hw_write_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR, mpi_opts);
|
|
|
+
|
|
|
+ err = hw_atl_utils_fw_rpc_call(self, sizeof(*msg));
|
|
|
+ if (err < 0)
|
|
|
+ goto err_exit;
|
|
|
+
|
|
|
+ /* Set bit 0x36C.24 */
|
|
|
+ mpi_opts |= HW_ATL_FW2X_CTRL_WOL;
|
|
|
+ aq_hw_write_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR, mpi_opts);
|
|
|
+
|
|
|
+ AQ_HW_WAIT_FOR((aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE2_ADDR) &
|
|
|
+ HW_ATL_FW2X_CTRL_WOL), 1U, 10000U);
|
|
|
+
|
|
|
+err_exit:
|
|
|
+ return err;
|
|
|
+}
|
|
|
+
|
|
|
+static int aq_fw2x_set_power(struct aq_hw_s *self, unsigned int power_state,
|
|
|
+ u8 *mac)
|
|
|
+{
|
|
|
+ int err = 0;
|
|
|
+
|
|
|
+ if (self->aq_nic_cfg->wol & AQ_NIC_WOL_ENABLED) {
|
|
|
+ err = aq_fw2x_set_sleep_proxy(self, mac);
|
|
|
+ if (err < 0)
|
|
|
+ goto err_exit;
|
|
|
+ err = aq_fw2x_set_wol_params(self, mac);
|
|
|
+ }
|
|
|
+
|
|
|
+err_exit:
|
|
|
+ return err;
|
|
|
+}
|
|
|
+
|
|
|
+static int aq_fw2x_set_eee_rate(struct aq_hw_s *self, u32 speed)
|
|
|
+{
|
|
|
+ u32 mpi_opts = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR);
|
|
|
+
|
|
|
+ aq_fw2x_upd_eee_rate_bits(self, &mpi_opts, speed);
|
|
|
+
|
|
|
+ aq_hw_write_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR, mpi_opts);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int aq_fw2x_get_eee_rate(struct aq_hw_s *self, u32 *rate,
|
|
|
+ u32 *supported_rates)
|
|
|
+{
|
|
|
+ u32 mpi_state;
|
|
|
+ u32 caps_hi;
|
|
|
+ int err = 0;
|
|
|
+ u32 addr = self->mbox_addr + offsetof(struct hw_atl_utils_mbox, info) +
|
|
|
+ offsetof(struct hw_aq_info, caps_hi);
|
|
|
+
|
|
|
+ err = hw_atl_utils_fw_downld_dwords(self, addr, &caps_hi,
|
|
|
+ sizeof(caps_hi) / sizeof(u32));
|
|
|
+
|
|
|
+ if (err)
|
|
|
+ return err;
|
|
|
+
|
|
|
+ *supported_rates = fw2x_to_eee_mask(caps_hi);
|
|
|
+
|
|
|
+ mpi_state = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE2_ADDR);
|
|
|
+ *rate = fw2x_to_eee_mask(mpi_state);
|
|
|
+
|
|
|
+ return err;
|
|
|
+}
|
|
|
+
|
|
|
static int aq_fw2x_renegotiate(struct aq_hw_s *self)
|
|
|
{
|
|
|
u32 mpi_opts = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR);
|
|
@@ -247,5 +461,8 @@ const struct aq_fw_ops aq_fw_2x_ops = {
|
|
|
.set_state = aq_fw2x_set_state,
|
|
|
.update_link_status = aq_fw2x_update_link_status,
|
|
|
.update_stats = aq_fw2x_update_stats,
|
|
|
- .set_flow_control = aq_fw2x_set_flow_control,
|
|
|
+ .set_power = aq_fw2x_set_power,
|
|
|
+ .set_eee_rate = aq_fw2x_set_eee_rate,
|
|
|
+ .get_eee_rate = aq_fw2x_get_eee_rate,
|
|
|
+ .set_flow_control = aq_fw2x_set_flow_control,
|
|
|
};
|