[PATCH] mailmap: add entry for

2020-09-28 Thread Mark Starovoytov
Map the address to my private mail, because my Marvell account has been 
suspended.

Signed-off-by: Mark Starovoytov 
---
 .mailmap | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.mailmap b/.mailmap
index a780211468e4..f7bd4ee8c4b9 100644
--- a/.mailmap
+++ b/.mailmap
@@ -195,6 +195,7 @@ Maciej W. Rozycki  
 Marcin Nowakowski  
 Marc Zyngier  
 Mark Brown 
+Mark Starovoytov  
 Mark Yao  
 Martin Kepplinger  
 Martin Kepplinger  
-- 
2.17.1




[PATCH] mailmap: add entry for

2020-08-24 Thread Mark Starovoytov
Map the address to my private mail, because my Marvell account has been 
suspended.

Signed-off-by: Mark Starovoytov 
---
 .mailmap | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.mailmap b/.mailmap
index 332c7833057f..4cf029cff065 100644
--- a/.mailmap
+++ b/.mailmap
@@ -191,6 +191,7 @@ Maciej W. Rozycki  
 Marcin Nowakowski  
 Marc Zyngier  
 Mark Brown 
+Mark Starovoytov  
 Mark Yao  
 Martin Kepplinger  
 Martin Kepplinger  
-- 
2.17.1




[PATCH net] net: atlantic: disable PTP on AQC111, AQC112

2020-07-17 Thread Mark Starovoytov
From: Nikita Danilov 

This patch disables PTP on AQC111 and AQC112 due to a known HW issue,
which can cause datapath issues.

Ideally PTP block should have been disabled via PHY provisioning, but
unfortunately many units have been shipped with enabled PTP block.
Thus, we have to work around this in the driver.

Fixes: dbcd6806af420 ("net: aquantia: add support for Phy access")
Signed-off-by: Nikita Danilov 
Signed-off-by: Mark Starovoytov 
Signed-off-by: Igor Russkikh 
---
 .../net/ethernet/aquantia/atlantic/aq_hw.h|  1 +
 .../net/ethernet/aquantia/atlantic/aq_nic.c   |  9 ++
 .../net/ethernet/aquantia/atlantic/aq_nic.h   |  2 ++
 .../net/ethernet/aquantia/atlantic/aq_phy.c   | 29 +--
 .../net/ethernet/aquantia/atlantic/aq_phy.h   |  8 +++--
 .../aquantia/atlantic/hw_atl/hw_atl_b0.c  | 19 
 .../aquantia/atlantic/hw_atl/hw_atl_b0.h  | 10 +++
 7 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h 
b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
index ed5b465bc664..992fedbe4ce3 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
@@ -64,6 +64,7 @@ struct aq_hw_caps_s {
u8 rx_rings;
bool flow_control;
bool is_64_dma;
+   u32 quirks;
u32 priv_data_len;
 };
 
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c 
b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index 4435c6374f7e..7c7bf6bf163f 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -415,6 +415,15 @@ int aq_nic_init(struct aq_nic_s *self)
self->aq_nic_cfg.aq_hw_caps->media_type == AQ_HW_MEDIA_TYPE_TP) {
self->aq_hw->phy_id = HW_ATL_PHY_ID_MAX;
err = aq_phy_init(self->aq_hw);
+
+   /* Disable the PTP on NICs where it's known to cause datapath
+* problems.
+* Ideally this should have been done by PHY provisioning, but
+* many units have been shipped with enabled PTP block already.
+*/
+   if (self->aq_nic_cfg.aq_hw_caps->quirks & AQ_NIC_QUIRK_BAD_PTP)
+   if (self->aq_hw->phy_id != HW_ATL_PHY_ID_MAX)
+   aq_phy_disable_ptp(self->aq_hw);
}
 
for (i = 0U; i < self->aq_vecs; i++) {
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h 
b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
index 2ab003065e62..439ce9692dac 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
@@ -81,6 +81,8 @@ struct aq_nic_cfg_s {
 #define AQ_NIC_FLAG_ERR_UNPLUG  0x4000U
 #define AQ_NIC_FLAG_ERR_HW  0x8000U
 
+#define AQ_NIC_QUIRK_BAD_PTPBIT(0)
+
 #define AQ_NIC_WOL_MODES(WAKE_MAGIC |\
 WAKE_PHY)
 
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_phy.c 
b/drivers/net/ethernet/aquantia/atlantic/aq_phy.c
index 51ae921e3e1f..949ac2351701 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_phy.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_phy.c
@@ -1,10 +1,14 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/* aQuantia Corporation Network Driver
- * Copyright (C) 2018-2019 aQuantia Corporation. All rights reserved
+/* Atlantic Network Driver
+ *
+ * Copyright (C) 2018-2019 aQuantia Corporation
+ * Copyright (C) 2019-2020 Marvell International Ltd.
  */
 
 #include "aq_phy.h"
 
+#define HW_ATL_PTP_DISABLE_MSK BIT(10)
+
 bool aq_mdio_busy_wait(struct aq_hw_s *aq_hw)
 {
int err = 0;
@@ -145,3 +149,24 @@ bool aq_phy_init(struct aq_hw_s *aq_hw)
 
return true;
 }
+
+void aq_phy_disable_ptp(struct aq_hw_s *aq_hw)
+{
+   static const u16 ptp_registers[] = {
+   0x031e,
+   0x031d,
+   0x031c,
+   0x031b,
+   };
+   u16 val;
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ptp_registers); i++) {
+   val = aq_phy_read_reg(aq_hw, MDIO_MMD_VEND1,
+ ptp_registers[i]);
+
+   aq_phy_write_reg(aq_hw, MDIO_MMD_VEND1,
+ptp_registers[i],
+val & ~HW_ATL_PTP_DISABLE_MSK);
+   }
+}
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_phy.h 
b/drivers/net/ethernet/aquantia/atlantic/aq_phy.h
index 84b72ad04a4a..86cc1ee836e2 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_phy.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_phy.h
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/* aQuantia Corporation Network Driver
- * Copyright (C) 2018-2019 aQuantia Corporation. All rights reserved
+/* Atlantic Network Driver
+ *
+ * Copyright (C) 2018-2019 aQuantia Corporation
+ * Copyright (C) 2019-2020 Marvell

[PATCH net-next 1/2] net: atlantic: align return value of ver_match function with function name

2020-07-17 Thread Mark Starovoytov
This patch aligns the return value of hw_atl_utils_ver_match function with
its name.
Change the return type to bool, because it's better aligned with the actual
usage. Return true when the version matches, false otherwise.

Signed-off-by: Mark Starovoytov 
Signed-off-by: Igor Russkikh 
---
 .../aquantia/atlantic/hw_atl/hw_atl_utils.c   | 29 +--
 .../aquantia/atlantic/hw_atl/hw_atl_utils.h   |  2 +-
 .../aquantia/atlantic/hw_atl2/hw_atl2_utils.c |  3 +-
 3 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
index bf4c41cc312b..22f68e4a638c 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
@@ -72,14 +72,11 @@ int hw_atl_utils_initfw(struct aq_hw_s *self, const struct 
aq_fw_ops **fw_ops)
 
self->fw_ver_actual = hw_atl_utils_get_fw_version(self);
 
-   if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
-  self->fw_ver_actual) == 0) {
+   if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X, self->fw_ver_actual)) {
*fw_ops = _fw_1x_ops;
-   } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_2X,
- self->fw_ver_actual) == 0) {
+   } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_2X, 
self->fw_ver_actual)) {
*fw_ops = _fw_2x_ops;
-   } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_3X,
- self->fw_ver_actual) == 0) {
+   } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_3X, 
self->fw_ver_actual)) {
*fw_ops = _fw_2x_ops;
} else {
aq_pr_err("Bad FW version detected: %x\n",
@@ -262,9 +259,9 @@ int hw_atl_utils_soft_reset(struct aq_hw_s *self)
/* FW 1.x may bootup in an invalid POWER state (WOL feature).
 * We should work around this by forcing its state back to DEINIT
 */
-   if (!hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
-   aq_hw_read_reg(self,
-  HW_ATL_MPI_FW_VERSION))) {
+   if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
+  aq_hw_read_reg(self,
+ HW_ATL_MPI_FW_VERSION))) {
int err = 0;
 
hw_atl_utils_mpi_set_state(self, MPI_DEINIT);
@@ -434,20 +431,20 @@ int hw_atl_write_fwsettings_dwords(struct aq_hw_s *self, 
u32 offset, u32 *p,
 p, cnt, MCP_AREA_SETTINGS);
 }
 
-int hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual)
+bool hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual)
 {
const u32 dw_major_mask = 0xff00U;
const u32 dw_minor_mask = 0x00ffU;
-   int err = 0;
+   bool ver_match;
 
-   err = (dw_major_mask & (ver_expected ^ ver_actual)) ? -EOPNOTSUPP : 0;
-   if (err < 0)
+   ver_match = (dw_major_mask & (ver_expected ^ ver_actual)) ? false : 
true;
+   if (!ver_match)
goto err_exit;
-   err = ((dw_minor_mask & ver_expected) > (dw_minor_mask & ver_actual)) ?
-   -EOPNOTSUPP : 0;
+   ver_match = ((dw_minor_mask & ver_expected) > (dw_minor_mask & 
ver_actual)) ?
+   false : true;
 
 err_exit:
-   return err;
+   return ver_match;
 }
 
 static int hw_atl_utils_init_ucp(struct aq_hw_s *self,
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
index 0b4b54fc1de0..f5901f8e3907 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
@@ -635,7 +635,7 @@ int hw_atl_utils_fw_rpc_call(struct aq_hw_s *self, unsigned 
int rpc_size);
 int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
 struct hw_atl_utils_fw_rpc **rpc);
 
-int hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual);
+bool hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual);
 
 extern const struct aq_fw_ops aq_fw_1x_ops;
 extern const struct aq_fw_ops aq_fw_2x_ops;
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c
index f3766780e975..0fe6257d9c08 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c
@@ -36,8 +36,7 @@ int hw_atl2_utils_initfw(struct aq_hw_s *self, const struct 
aq_fw_ops **fw_ops)
 
self->fw_ver_actual = hw_atl2_utils_get_fw_version(self);
 
-   if (hw_atl_utils_ver_match(HW_ATL2_FW_VER_1X,
-  self->fw_ver_actual) == 0) {
+  

[PATCH net-next 2/2] net: atlantic: add support for FW 4.x

2020-07-17 Thread Mark Starovoytov
From: Dmitry Bogdanov 

This patch adds support for FW 4.x, which is about to get into the
production for some products.
4.x is mostly compatible with 3.x, save for soft reset, which requires
the acquisition of 2 additional semaphores.
Other differences (e.g. absence of PTP support) are handled via
capabilities.

Note: 4.x targets specific products only. 3.x is still the main firmware
branch, which should be used by most users (at least for now).

Signed-off-by: Dmitry Bogdanov 
Signed-off-by: Mark Starovoytov 
Signed-off-by: Igor Russkikh 
---
 .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 17 +++--
 .../aquantia/atlantic/hw_atl/hw_atl_llh.h | 10 --
 .../atlantic/hw_atl/hw_atl_llh_internal.h | 11 --
 .../aquantia/atlantic/hw_atl/hw_atl_utils.c   | 35 +++
 4 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c
index d775b23025c1..9c3debae425f 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c
@@ -1,7 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/*
- * aQuantia Corporation Network Driver
- * Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved
+/* Atlantic Network Driver
+ *
+ * Copyright (C) 2014-2019 aQuantia Corporation
+ * Copyright (C) 2019-2020 Marvell International Ltd.
  */
 
 /* File hw_atl_llh.c: Definitions of bitfield and register access functions for
@@ -1724,6 +1725,16 @@ u32 hw_atl_sem_mdio_get(struct aq_hw_s *self)
return hw_atl_reg_glb_cpu_sem_get(self, HW_ATL_FW_SM_MDIO);
 }
 
+u32 hw_atl_sem_reset1_get(struct aq_hw_s *self)
+{
+   return hw_atl_reg_glb_cpu_sem_get(self, HW_ATL_FW_SM_RESET1);
+}
+
+u32 hw_atl_sem_reset2_get(struct aq_hw_s *self)
+{
+   return hw_atl_reg_glb_cpu_sem_get(self, HW_ATL_FW_SM_RESET2);
+}
+
 u32 hw_atl_scrpad_get(struct aq_hw_s *aq_hw, u32 scratch_scp)
 {
return aq_hw_read_reg(aq_hw,
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h
index 61a6f70c51cd..f0954711df24 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h
@@ -1,7 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * aQuantia Corporation Network Driver
- * Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved
+/* Atlantic Network Driver
+ *
+ * Copyright (C) 2014-2019 aQuantia Corporation
+ * Copyright (C) 2019-2020 Marvell International Ltd.
  */
 
 /* File hw_atl_llh.h: Declarations of bitfield and register access functions 
for
@@ -838,6 +839,9 @@ u32 hw_atl_sem_ram_get(struct aq_hw_s *self);
 /* get global microprocessor mdio semaphore */
 u32 hw_atl_sem_mdio_get(struct aq_hw_s *self);
 
+u32 hw_atl_sem_reset1_get(struct aq_hw_s *self);
+u32 hw_atl_sem_reset2_get(struct aq_hw_s *self);
+
 /* get global microprocessor scratch pad register */
 u32 hw_atl_scrpad_get(struct aq_hw_s *aq_hw, u32 scratch_scp);
 
diff --git 
a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h
index 7430ff025134..ee11cb88325e 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h
@@ -1,7 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * aQuantia Corporation Network Driver
- * Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved
+/* Atlantic Network Driver
+ *
+ * Copyright (C) 2014-2019 aQuantia Corporation
+ * Copyright (C) 2019-2020 Marvell International Ltd.
  */
 
 /* File hw_atl_llh_internal.h: Preprocessor definitions
@@ -2837,7 +2838,11 @@
 /* Default value of bitfield MDIO Address [F:0] */
 #define HW_ATL_MDIO_ADDRESS_DEFAULT 0x0
 
+#define HW_ATL_MIF_RESET_TIMEOUT_ADR 0x0348
+
 #define HW_ATL_FW_SM_MDIO   0x0U
 #define HW_ATL_FW_SM_RAM0x2U
+#define HW_ATL_FW_SM_RESET1 0x3U
+#define HW_ATL_FW_SM_RESET2 0x4U
 
 #endif /* HW_ATL_LLH_INTERNAL_H */
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
index 22f68e4a638c..cacab3352cb8 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
@@ -46,6 +46,7 @@
 #define HW_ATL_FW_VER_1X 0x01050006U
 #define HW_ATL_FW_VER_2X 0x0200U
 #define HW_ATL_FW_VER_3X 0x0300U
+#define HW_ATL_FW_VER_4X 0x0400U
 
 #define FORCE_FLASHLESS 0
 
@@ -78,6 +79,8 @@ int hw_atl_utils_initfw(struct aq_hw_s *self, const struct 
aq_fw_ops **fw_ops)
*fw_ops = _fw_2x_ops;
} else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_3X, 
self->fw_ver_actual)) {
*fw_ops = _fw_2x_

[PATCH net-next 0/2] net: atlantic: add support for FW 4.x

2020-07-17 Thread Mark Starovoytov
This patch set adds support for FW 4.x, which is about to get into the
production for some products.
4.x is mostly compatible with 3.x, save for soft reset, which requires
the acquisition of 2 additional semaphores.
Other differences (e.g. absence of PTP support) are handled via
capabilities.

Note: 4.x targets specific products only. 3.x is still the main firmware
branch, which should be used by most users (at least for now).

Dmitry Bogdanov (1):
  net: atlantic: add support for FW 4.x

Mark Starovoytov (1):
  net: atlantic: align return value of ver_match function with function
name

 .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 17 +-
 .../aquantia/atlantic/hw_atl/hw_atl_llh.h | 10 +++-
 .../atlantic/hw_atl/hw_atl_llh_internal.h | 11 +++-
 .../aquantia/atlantic/hw_atl/hw_atl_utils.c   | 58 +--
 .../aquantia/atlantic/hw_atl/hw_atl_utils.h   |  2 +-
 .../aquantia/atlantic/hw_atl2/hw_atl2_utils.c |  3 +-
 6 files changed, 70 insertions(+), 31 deletions(-)

-- 
2.25.1