net: ethernet: aquantia: Fixed incorrect buff->len calculation.
authorPavel Belous <pavel.belous@aquantia.com>
Mon, 20 Feb 2017 19:36:48 +0000 (22:36 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Feb 2017 22:11:09 +0000 (17:11 -0500)
rxd_wb->pkt_len is the total length of the packet.
If we received a large packet (with length > AQ_CFG_RX_FRAME_MAX) then we
will get multiple buffers. We need to fix the length of the last buffer.

Signed-off-by: Pavel Belous <pavel.belous@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c

index 1f388054a6c71debe2f33e51fac3426b10c8162b..a2b746a2dd50b8825250f5ab1de8a01b5afb32c9 100644 (file)
@@ -659,8 +659,8 @@ static int hw_atl_a0_hw_ring_rx_receive(struct aq_hw_s *self,
                        }
 
                        if (HW_ATL_A0_RXD_WB_STAT2_EOP & rxd_wb->status) {
-                               buff->len = (rxd_wb->pkt_len &
-                                               (AQ_CFG_RX_FRAME_MAX - 1U));
+                               buff->len = rxd_wb->pkt_len %
+                                       AQ_CFG_RX_FRAME_MAX;
                                buff->len = buff->len ?
                                        buff->len : AQ_CFG_RX_FRAME_MAX;
                                buff->next = 0U;
index e7e694f693bddfced346c4a987feff7fefcd65e1..cab2931dab9ac354821e4a30bb8517ccfe0041eb 100644 (file)
@@ -673,8 +673,8 @@ static int hw_atl_b0_hw_ring_rx_receive(struct aq_hw_s *self,
                        }
 
                        if (HW_ATL_B0_RXD_WB_STAT2_EOP & rxd_wb->status) {
-                               buff->len = (rxd_wb->pkt_len &
-                                               (AQ_CFG_RX_FRAME_MAX - 1U));
+                               buff->len = rxd_wb->pkt_len %
+                                       AQ_CFG_RX_FRAME_MAX;
                                buff->len = buff->len ?
                                        buff->len : AQ_CFG_RX_FRAME_MAX;
                                buff->next = 0U;