Marvell atlantic 2020/02 updates
Subsystems (3)
cover Marvell atlantic 2020/02 updates
Hi David, here is another set of bugfixes on AQC family found on last integration phase.
Dmitry Bezrukov (1):
net: atlantic: checksum compat issue
Dmitry Bogdanov (2):
net: atlantic: check rpc result and wait for rpc address
net: atlantic: fix out of range usage of active_vlans array
Egor Pomozov (1):
net: atlantic: ptp gpio adjustments
Nikita Danilov (1):
net: atlantic: better loopback mode handling
Pavel Belous (3):
net: atlantic: fix use after free kasan warn
net: atlantic: fix potential error handling
net: atlantic: possible fault in transition to hibernation
.../ethernet/aquantia/atlantic/aq_ethtool.c | 5 +++++ .../ethernet/aquantia/atlantic/aq_filters.c | 2 +- .../net/ethernet/aquantia/atlantic/aq_hw.h | 2 ++ .../net/ethernet/aquantia/atlantic/aq_nic.c | 8 +++---- .../ethernet/aquantia/atlantic/aq_pci_func.c | 13 ++++++----- .../net/ethernet/aquantia/atlantic/aq_ring.c | 10 ++++++--- .../net/ethernet/aquantia/atlantic/aq_ring.h | 3 ++- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 22 ++++++++++++------- .../aquantia/atlantic/hw_atl/hw_atl_utils.c | 19 ++++++++++++++-- .../atlantic/hw_atl/hw_atl_utils_fw2x.c | 12 ++++++++++ 10 files changed, 71 insertions(+), 25 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/8 net: atlantic: checksum compat issue
From: Dmitry Bezrukov <[email protected]>
Yet another checksum offload compatibility issue was found.
The known issue is that AQC HW marks tcp packets with 0xFFFF checksum as invalid (1). This is workarounded in driver, passing all the suspicious packets up to the stack for further csum validation.
Another HW problem (2) is that it hides invalid csum of LRO aggregated packets inside of the individual descriptors. That was workarounded by forced scan of all LRO descriptors for checksum errors.
However the scan logic was joint for both LRO and multi-descriptor packets (jumbos). And this causes the issue.
We have to drop LRO packets with the detected bad checksum because of (2), but we have to pass jumbo packets to stack because of (1).
When using windows tcp partner with jumbo frames but with LSO disabled driver discards such frames as bad checksummed. But only LRO frames should be dropped, not jumbos.
On such a configurations tcp stream have a chance of drops and stucks.
(1) 76f254d4afe2 ("net: aquantia: tcp checksum 0xffff being handled incorrectly")
(2) d08b9a0a3ebd ("net: aquantia: do not pass lro session with invalid tcp checksum")
--- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 3 ++- drivers/net/ethernet/aquantia/atlantic/aq_ring.h | 3 ++- drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +2 -1
@@ -351,7 +351,8 @@ int aq_ring_rx_clean(struct aq_ring_s *self, err =0 ; goto err_exit; } -if (buff->is_error || buff->is_cso_err) { +if (buff->is_error || + (buff->is_lro && buff->is_cso_err)) { buff_ = buff; do { next_ = buff_->next,
drivers/net/ethernet/aquantia/atlantic/aq_ring.h +2 -1
@@ -78,7 +78,8 @@ struct __packed aq_ring_buff_s { u32 is_cleaned:1; u32 is_error:1; u32 is_vlan:1; - u32 rsvd3:4; + u32 is_lro:1; + u32 rsvd3:3;u16 eop_index;u16 rsvd4; };
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +3 -2
@@ -823,6 +823,8 @@ static int hw_atl_b0_hw_ring_rx_receive(struct aq_hw_s *self, } } + buff->is_lro = !!(HW_ATL_B0_RXD_WB_STAT2_RSCCNT & + rxd_wb->status);if (HW_ATL_B0_RXD_WB_STAT2_EOP & rxd_wb->status) { buff->len = rxd_wb->pkt_len %AQ_CFG_RX_FRAME_MAX ;
@@ -835,8 +837,7 @@ static int hw_atl_b0_hw_ring_rx_receive(struct aq_hw_s *self, rxd_wb->pkt_len >AQ_CFG_RX_FRAME_MAX ?AQ_CFG_RX_FRAME_MAX : rxd_wb->pkt_len; -if (HW_ATL_B0_RXD_WB_STAT2_RSCCNT & - rxd_wb->status) { +if (buff->is_lro) {/* LRO */ buff->next = rxd_wb->next_desc_ptr; ++ring->stats.rx.lro_packets;
Signature · 1 line
2.17.1
PATCH 2/8 net: atlantic: check rpc result and wait for rpc address
In reply to Igor RusskikhArtificial HW reliability tests revealed a possible hangup in the driver. Normally, when device disappears from bus, all register reads returns 0xFFFFFFFF.
At remote procedure invocation towards FW there is a logic where result is compared with -1 in a loop.
That caused an infinite loop if hardware due to some issues disappears from bus.
Add extra result checks to prevent this.
--- .../aquantia/atlantic/hw_atl/hw_atl_utils.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +17 -2
@@ -22,6 +22,7 @@#define HW_ATL_MIF_ADDR 0x0208U#define HW_ATL_MIF_VAL 0x020CU +#define HW_ATL_MPI_RPC_ADDR 0x0334U#define HW_ATL_RPC_CONTROL_ADR 0x0338U#define HW_ATL_RPC_STATE_ADR 0x033CU
@@ -53,15 +54,14 @@ enum mcp_area { };static int hw_atl_utils_ver_match (u32 ver_expected,u32 ver_actual); -static int hw_atl_utils_mpi_set_state (struct aq_hw_s *self,enum hal_atl_utils_fw_state_e state); -static u32 hw_atl_utils_get_mpi_mbox_tid (struct aq_hw_s *self);static u32 hw_atl_utils_mpi_get_state (struct aq_hw_s *self);static u32 hw_atl_utils_mif_cmd_get (struct aq_hw_s *self);static u32 hw_atl_utils_mif_addr_get (struct aq_hw_s *self);static u32 hw_atl_utils_rpc_state_get (struct aq_hw_s *self); +static u32 aq_fw1x_rpc_get (struct aq_hw_s *self);int hw_atl_utils_initfw (struct aq_hw_s *self,const struct aq_fw_ops **fw_ops) {
@@ -476,6 +476,10 @@ static int hw_atl_utils_init_ucp(struct aq_hw_s *self, self, self->mbox_addr, self->mbox_addr !=0U , 1000U, 10000U); + err =readx_poll_timeout_atomic (aq_fw1x_rpc_get, self, + self->rpc_addr, + self->rpc_addr !=0U , +1000U ,100000U );return err; }
@@ -531,6 +535,12 @@ int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self, self, fw.val, sw.tid == fw.tid, 1000U, 100000U); +if (err <0 ) + goto err_exit; + + err =aq_hw_err_from_flags (self); +if (err <0 ) + goto err_exit;if (fw.len ==0xFFFFU ) { err =hw_atl_utils_fw_rpc_call (self, sw.len);
@@ -1025,6 +1035,11 @@ static u32 hw_atl_utils_rpc_state_get(struct aq_hw_s *self)return aq_hw_read_reg (self,HW_ATL_RPC_STATE_ADR ); } +static u32 aq_fw1x_rpc_get (struct aq_hw_s *self) +{ +return aq_hw_read_reg (self,HW_ATL_MPI_RPC_ADDR ); +} +const struct aq_fw_ops aq_fw_1x_ops = { .init = hw_atl_utils_mpi_create, .deinit = hw_atl_fw1x_deinit,
Signature · 1 line
2.17.1
PATCH 3/8 net: atlantic: ptp gpio adjustments
In reply to Igor RusskikhFrom: Egor Pomozov <[email protected]>
Clock adjustment data should be passed to FW as well, otherwise in some cases a drift was observed when using GPIO features.
--- drivers/net/ethernet/aquantia/atlantic/aq_hw.h | 2 ++ .../ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c | 4 +++- .../aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +2 -0
@@ -337,6 +337,8 @@ struct aq_fw_ops {void (*enable_ptp)(struct aq_hw_s *self,int enable); +void (*adjust_ptp)(struct aq_hw_s *self,uint64_t adj); +int (*set_eee_rate)(struct aq_hw_s *self,u32 speed); int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +3 -1
@@ -1162,6 +1162,8 @@ static int hw_atl_b0_adj_sys_clock(struct aq_hw_s *self, s64 delta) { self->ptp_clk_offset += delta; + self->aq_fw_ops->adjust_ptp (self, self->ptp_clk_offset); +return 0 ; }
@@ -1212,7 +1214,7 @@ static int hw_atl_b0_gpio_pulse(struct aq_hw_s *self, u32 index, fwreq.ptp_gpio_ctrl.index = index; fwreq.ptp_gpio_ctrl.period = period;/* Apply time offset */ - fwreq.ptp_gpio_ctrl.start = start - self->ptp_clk_offset; + fwreq.ptp_gpio_ctrl.start = start; size =sizeof (fwreq.msg_id) +sizeof (fwreq.ptp_gpio_ctrl);return self->aq_fw_ops->send_fw_request (self, &fwreq, size);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c +12 -0
@@ -30,6 +30,9 @@#define HW_ATL_FW3X_EXT_CONTROL_ADDR 0x378#define HW_ATL_FW3X_EXT_STATE_ADDR 0x37c +#define HW_ATL_FW3X_PTP_ADJ_LSW_ADDR 0x50a0 +#define HW_ATL_FW3X_PTP_ADJ_MSW_ADDR 0x50a4 +#define HW_ATL_FW2X_CAP_PAUSE BIT(CAPS_HI_PAUSE)#define HW_ATL_FW2X_CAP_ASYM_PAUSE BIT(CAPS_HI_ASYMMETRIC_PAUSE)#define HW_ATL_FW2X_CAP_SLEEP_PROXY BIT(CAPS_HI_SLEEP_PROXY)
@@ -475,6 +478,14 @@ static void aq_fw3x_enable_ptp(struct aq_hw_s *self, int enable)aq_hw_write_reg (self,HW_ATL_FW3X_EXT_CONTROL_ADDR , ptp_opts); } +static void aq_fw3x_adjust_ptp (struct aq_hw_s *self,uint64_t adj) +{ +aq_hw_write_reg (self,HW_ATL_FW3X_PTP_ADJ_LSW_ADDR , + (adj >>0 ) &0xffffffff ); +aq_hw_write_reg (self,HW_ATL_FW3X_PTP_ADJ_MSW_ADDR , + (adj >>32 ) &0xffffffff ); +} +static int aq_fw2x_led_control (struct aq_hw_s *self,u32 mode) {if (self->fw_ver_actual <HW_ATL_FW_VER_LED )
@@ -633,4 +644,5 @@ const struct aq_fw_ops aq_fw_2x_ops = { .enable_ptp = aq_fw3x_enable_ptp, .led_control = aq_fw2x_led_control, .set_phyloopback = aq_fw2x_set_phyloopback, + .adjust_ptp = aq_fw3x_adjust_ptp, };
Signature · 1 line
2.17.1
PATCH 4/8 net: atlantic: better loopback mode handling
In reply to Igor RusskikhFrom: Nikita Danilov <[email protected]>
Add checks to not enable multiple loopback modes simultaneously, It was also discovered that for dma loopback to function correctly promisc mode should be enabled on device.
--- drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c | 5 +++++ .../ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +5 -0
@@ -722,6 +722,11 @@ static int aq_ethtool_set_priv_flags(struct net_device *ndev, u32 flags)if (flags & ~AQ_PRIV_FLAGS_MASK )return -EOPNOTSUPP ; +if (hweight32 ((flags | priv_flags) &AQ_HW_LOOPBACK_MASK ) >1 ) { +netdev_info (ndev,"Can't enable more than one loopback simultaneously\n" ); +return -EINVAL ; + } + cfg->priv_flags = flags;if ((priv_flags ^ flags) &BIT (AQ_HW_LOOPBACK_DMA_NET )) {
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +8 -5
@@ -885,13 +885,16 @@ static int hw_atl_b0_hw_packet_filter_set(struct aq_hw_s *self, {struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;unsigned int i =0U ; +u32 vlan_promisc; +u32 l2_promisc; -hw_atl_rpfl2promiscuous_mode_en_set (self, -IS_FILTER_ENABLED (IFF_PROMISC )); + l2_promisc =IS_FILTER_ENABLED (IFF_PROMISC ) || + !!(cfg->priv_flags &BIT (AQ_HW_LOOPBACK_DMA_NET )); + vlan_promisc = l2_promisc || cfg->is_vlan_force_promisc; -hw_atl_rpf_vlan_prom_mode_en_set (self, -IS_FILTER_ENABLED (IFF_PROMISC ) || - cfg->is_vlan_force_promisc); +hw_atl_rpfl2promiscuous_mode_en_set (self, l2_promisc); + +hw_atl_rpf_vlan_prom_mode_en_set (self, vlan_promisc); hw_atl_rpfl2multicast_flr_en_set(self, IS_FILTER_ENABLED(IFF_ALLMULTI) &&
Signature · 1 line
2.17.1
PATCH 5/8 net: atlantic: fix use after free kasan warn
In reply to Igor RusskikhFrom: Pavel Belous <[email protected]>
skb->len is used to calculate statistics after xmit invocation.
Under a stress load it may happen that skb will be xmited, rx interrupt will come and skb will be freed, all before xmit function is even returned.
Eventually, skb->len will access unallocated area.
Moving stats calculation into tx_clean routine.
--- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 4 ---- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +0 -4
@@ -655,10 +655,6 @@ int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb)if (likely (frags)) { err = self->aq_hw_ops->hw_ring_tx_xmit (self->aq_hw, ring, frags); -if (err >=0 ) { - ++ring->stats.tx.packets; - ring->stats.tx.bytes += skb->len; - } }else { err =NETDEV_TX_BUSY ; }
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +5 -2
@@ -272,9 +272,12 @@ bool aq_ring_tx_clean(struct aq_ring_s *self) } } -if (unlikely (buff->is_eop)) -dev_kfree_skb_any (buff->skb); +if (unlikely (buff->is_eop)) { + ++self->stats.rx.packets; + self->stats.tx.bytes += buff->skb->len; +dev_kfree_skb_any (buff->skb); + } buff->pa =0U ; buff->eop_index =0xffffU ; self->sw_head =aq_ring_next_dx (self, self->sw_head);
Signature · 1 line
2.17.1
PATCH 6/8 net: atlantic: fix potential error handling
In reply to Igor RusskikhFrom: Pavel Belous <[email protected]>
Code inspection found that in case of mapping error we do return current 'ret' value. But beside error, it is used to count number of descriptors allocated for the packet. In that case map_skb function could return '1'.
Changing it to return zero (number of mapped descriptors for skb)
--- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +3 -1
@@ -533,8 +533,10 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb, dx_buff->len, DMA_TO_DEVICE); -if (unlikely (dma_mapping_error (aq_nic_get_dev (self), dx_buff->pa))) +if (unlikely (dma_mapping_error (aq_nic_get_dev (self), dx_buff->pa))) { + ret =0 ; goto exit; + } first = dx_buff; dx_buff->len_pkt = skb->len;
Signature · 1 line
2.17.1
PATCH 7/8 net: atlantic: possible fault in transition to hibernation
In reply to Igor RusskikhFrom: Pavel Belous <[email protected]>
during hibernation freeze, aq_nic_stop could be invoked on a stopped device. That may cause panic on access to not yet allocated vector/ring structures.
Add a check to stop device if it is not yet stopped.
Similiarly after freeze in hibernation thaw, aq_nic_start could be invoked on a not initialized net device. Result will be the same.
Add a check to start device if it is initialized. In our case, this is the same as started.
--- .../net/ethernet/aquantia/atlantic/aq_pci_func.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +8 -5
@@ -359,7 +359,8 @@ static int aq_suspend_common(struct device *dev, bool deep)netif_device_detach (nic->ndev);netif_tx_stop_all_queues (nic->ndev); -aq_nic_stop (nic); +if (netif_running (nic->ndev)) +aq_nic_stop (nic);if (deep) {aq_nic_deinit (nic, !nic->aq_hw->aq_nic_cfg->wol);
@@ -375,7 +376,7 @@ static int atl_resume_common(struct device *dev, bool deep) {struct pci_dev *pdev =to_pci_dev (dev);struct aq_nic_s *nic; -int ret; +int ret =0 ; nic =pci_get_drvdata (pdev);
@@ -390,9 +391,11 @@ static int atl_resume_common(struct device *dev, bool deep) goto err_exit; } - ret =aq_nic_start (nic); -if (ret) - goto err_exit; +if (netif_running (nic->ndev)) { + ret =aq_nic_start (nic); +if (ret) + goto err_exit; + }netif_device_attach (nic->ndev);netif_tx_start_all_queues (nic->ndev);
Signature · 1 line
2.17.1
David Miller
maintainerFrom: Igor Russkikh <[email protected]>
Date: Fri, 14 Feb 2020 18:44:50 +0300
Quoted 2 lines
Hi David, here is another set of bugfixes on AQC family found on last integration phase.
Series applied, thanks.