Commit dd14043a authored by David S. Miller's avatar David S. Miller

Merge branch 'lan743x-next'

Raju Lakkaraju says:

====================
net: lan743x: Fix to use multiqueue start/stop APIs

This patch series address the fix to use multiqueue start/stop APIs and Add Rx IP and TCP checksum offload

Changes:
========
V1 -> V2:
 - Fix the sparse warnings

V0 -> V1:
 - Remove chip SKU check conditionals
 - Update the changes description
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ceef59b5 cd691050
...@@ -1585,6 +1585,9 @@ static void lan743x_rfe_set_multicast(struct lan743x_adapter *adapter) ...@@ -1585,6 +1585,9 @@ static void lan743x_rfe_set_multicast(struct lan743x_adapter *adapter)
rfctl |= RFE_CTL_AM_; rfctl |= RFE_CTL_AM_;
} }
if (netdev->features & NETIF_F_RXCSUM)
rfctl |= RFE_CTL_IP_COE_ | RFE_CTL_TCP_UDP_COE_;
memset(hash_table, 0, DP_SEL_VHF_HASH_LEN * sizeof(u32)); memset(hash_table, 0, DP_SEL_VHF_HASH_LEN * sizeof(u32));
if (netdev_mc_count(netdev)) { if (netdev_mc_count(netdev)) {
struct netdev_hw_addr *ha; struct netdev_hw_addr *ha;
...@@ -2066,11 +2069,13 @@ static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx, ...@@ -2066,11 +2069,13 @@ static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx,
{ {
int required_number_of_descriptors = 0; int required_number_of_descriptors = 0;
unsigned int start_frame_length = 0; unsigned int start_frame_length = 0;
netdev_tx_t retval = NETDEV_TX_OK;
unsigned int frame_length = 0; unsigned int frame_length = 0;
unsigned int head_length = 0; unsigned int head_length = 0;
unsigned long irq_flags = 0; unsigned long irq_flags = 0;
bool do_timestamp = false; bool do_timestamp = false;
bool ignore_sync = false; bool ignore_sync = false;
struct netdev_queue *txq;
int nr_frags = 0; int nr_frags = 0;
bool gso = false; bool gso = false;
int j; int j;
...@@ -2083,9 +2088,12 @@ static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx, ...@@ -2083,9 +2088,12 @@ static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx,
if (required_number_of_descriptors > (tx->ring_size - 1)) { if (required_number_of_descriptors > (tx->ring_size - 1)) {
dev_kfree_skb_irq(skb); dev_kfree_skb_irq(skb);
} else { } else {
/* save to overflow buffer */ /* save how many descriptors we needed to restart the queue */
tx->overflow_skb = skb; tx->rqd_descriptors = required_number_of_descriptors;
netif_stop_queue(tx->adapter->netdev); retval = NETDEV_TX_BUSY;
txq = netdev_get_tx_queue(tx->adapter->netdev,
tx->channel_number);
netif_tx_stop_queue(txq);
} }
goto unlock; goto unlock;
} }
...@@ -2144,15 +2152,15 @@ static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx, ...@@ -2144,15 +2152,15 @@ static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx,
unlock: unlock:
spin_unlock_irqrestore(&tx->ring_lock, irq_flags); spin_unlock_irqrestore(&tx->ring_lock, irq_flags);
return NETDEV_TX_OK; return retval;
} }
static int lan743x_tx_napi_poll(struct napi_struct *napi, int weight) static int lan743x_tx_napi_poll(struct napi_struct *napi, int weight)
{ {
struct lan743x_tx *tx = container_of(napi, struct lan743x_tx, napi); struct lan743x_tx *tx = container_of(napi, struct lan743x_tx, napi);
struct lan743x_adapter *adapter = tx->adapter; struct lan743x_adapter *adapter = tx->adapter;
bool start_transmitter = false;
unsigned long irq_flags = 0; unsigned long irq_flags = 0;
struct netdev_queue *txq;
u32 ioc_bit = 0; u32 ioc_bit = 0;
ioc_bit = DMAC_INT_BIT_TX_IOC_(tx->channel_number); ioc_bit = DMAC_INT_BIT_TX_IOC_(tx->channel_number);
...@@ -2163,24 +2171,20 @@ static int lan743x_tx_napi_poll(struct napi_struct *napi, int weight) ...@@ -2163,24 +2171,20 @@ static int lan743x_tx_napi_poll(struct napi_struct *napi, int weight)
/* clean up tx ring */ /* clean up tx ring */
lan743x_tx_release_completed_descriptors(tx); lan743x_tx_release_completed_descriptors(tx);
if (netif_queue_stopped(adapter->netdev)) { txq = netdev_get_tx_queue(adapter->netdev, tx->channel_number);
if (tx->overflow_skb) { if (netif_tx_queue_stopped(txq)) {
if (lan743x_tx_get_desc_cnt(tx, tx->overflow_skb) <= if (tx->rqd_descriptors) {
lan743x_tx_get_avail_desc(tx)) if (tx->rqd_descriptors <=
start_transmitter = true; lan743x_tx_get_avail_desc(tx)) {
tx->rqd_descriptors = 0;
netif_tx_wake_queue(txq);
}
} else { } else {
netif_wake_queue(adapter->netdev); netif_tx_wake_queue(txq);
} }
} }
spin_unlock_irqrestore(&tx->ring_lock, irq_flags); spin_unlock_irqrestore(&tx->ring_lock, irq_flags);
if (start_transmitter) {
/* space is now available, transmit overflow skb */
lan743x_tx_xmit_frame(tx, tx->overflow_skb);
tx->overflow_skb = NULL;
netif_wake_queue(adapter->netdev);
}
if (!napi_complete(napi)) if (!napi_complete(napi))
goto done; goto done;
...@@ -2304,10 +2308,7 @@ static void lan743x_tx_close(struct lan743x_tx *tx) ...@@ -2304,10 +2308,7 @@ static void lan743x_tx_close(struct lan743x_tx *tx)
lan743x_tx_release_all_descriptors(tx); lan743x_tx_release_all_descriptors(tx);
if (tx->overflow_skb) { tx->rqd_descriptors = 0;
dev_kfree_skb(tx->overflow_skb);
tx->overflow_skb = NULL;
}
lan743x_tx_ring_cleanup(tx); lan743x_tx_ring_cleanup(tx);
} }
...@@ -2387,7 +2388,7 @@ static int lan743x_tx_open(struct lan743x_tx *tx) ...@@ -2387,7 +2388,7 @@ static int lan743x_tx_open(struct lan743x_tx *tx)
(tx->channel_number)); (tx->channel_number));
netif_napi_add_tx_weight(adapter->netdev, netif_napi_add_tx_weight(adapter->netdev,
&tx->napi, lan743x_tx_napi_poll, &tx->napi, lan743x_tx_napi_poll,
tx->ring_size - 1); NAPI_POLL_WEIGHT);
napi_enable(&tx->napi); napi_enable(&tx->napi);
data = 0; data = 0;
...@@ -2549,6 +2550,7 @@ static int lan743x_rx_process_buffer(struct lan743x_rx *rx) ...@@ -2549,6 +2550,7 @@ static int lan743x_rx_process_buffer(struct lan743x_rx *rx)
int result = RX_PROCESS_RESULT_NOTHING_TO_DO; int result = RX_PROCESS_RESULT_NOTHING_TO_DO;
struct lan743x_rx_buffer_info *buffer_info; struct lan743x_rx_buffer_info *buffer_info;
int frame_length, buffer_length; int frame_length, buffer_length;
bool is_ice, is_tce, is_icsm;
int extension_index = -1; int extension_index = -1;
bool is_last, is_first; bool is_last, is_first;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -2595,6 +2597,9 @@ static int lan743x_rx_process_buffer(struct lan743x_rx *rx) ...@@ -2595,6 +2597,9 @@ static int lan743x_rx_process_buffer(struct lan743x_rx *rx)
frame_length = frame_length =
RX_DESC_DATA0_FRAME_LENGTH_GET_(le32_to_cpu(descriptor->data0)); RX_DESC_DATA0_FRAME_LENGTH_GET_(le32_to_cpu(descriptor->data0));
buffer_length = buffer_info->buffer_length; buffer_length = buffer_info->buffer_length;
is_ice = le32_to_cpu(descriptor->data1) & RX_DESC_DATA1_STATUS_ICE_;
is_tce = le32_to_cpu(descriptor->data1) & RX_DESC_DATA1_STATUS_TCE_;
is_icsm = le32_to_cpu(descriptor->data1) & RX_DESC_DATA1_STATUS_ICSM_;
netdev_dbg(netdev, "%s%schunk: %d/%d", netdev_dbg(netdev, "%s%schunk: %d/%d",
is_first ? "first " : " ", is_first ? "first " : " ",
...@@ -2663,6 +2668,10 @@ static int lan743x_rx_process_buffer(struct lan743x_rx *rx) ...@@ -2663,6 +2668,10 @@ static int lan743x_rx_process_buffer(struct lan743x_rx *rx)
if (is_last && rx->skb_head) { if (is_last && rx->skb_head) {
rx->skb_head->protocol = eth_type_trans(rx->skb_head, rx->skb_head->protocol = eth_type_trans(rx->skb_head,
rx->adapter->netdev); rx->adapter->netdev);
if (rx->adapter->netdev->features & NETIF_F_RXCSUM) {
if (!is_ice && !is_tce && !is_icsm)
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
netdev_dbg(netdev, "sending %d byte frame to OS", netdev_dbg(netdev, "sending %d byte frame to OS",
rx->skb_head->len); rx->skb_head->len);
napi_gro_receive(&rx->napi, rx->skb_head); napi_gro_receive(&rx->napi, rx->skb_head);
...@@ -3347,8 +3356,10 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev, ...@@ -3347,8 +3356,10 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
PCI11X1X_USED_TX_CHANNELS, PCI11X1X_USED_TX_CHANNELS,
LAN743X_USED_RX_CHANNELS); LAN743X_USED_RX_CHANNELS);
} else { } else {
netdev = devm_alloc_etherdev(&pdev->dev, netdev = devm_alloc_etherdev_mqs(&pdev->dev,
sizeof(struct lan743x_adapter)); sizeof(struct lan743x_adapter),
LAN743X_USED_TX_CHANNELS,
LAN743X_USED_RX_CHANNELS);
} }
if (!netdev) if (!netdev)
...@@ -3383,7 +3394,8 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev, ...@@ -3383,7 +3394,8 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
adapter->netdev->netdev_ops = &lan743x_netdev_ops; adapter->netdev->netdev_ops = &lan743x_netdev_ops;
adapter->netdev->ethtool_ops = &lan743x_ethtool_ops; adapter->netdev->ethtool_ops = &lan743x_ethtool_ops;
adapter->netdev->features = NETIF_F_SG | NETIF_F_TSO | NETIF_F_HW_CSUM; adapter->netdev->features = NETIF_F_SG | NETIF_F_TSO |
NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
adapter->netdev->hw_features = adapter->netdev->features; adapter->netdev->hw_features = adapter->netdev->features;
/* carrier off reporting is important to ethtool even BEFORE open */ /* carrier off reporting is important to ethtool even BEFORE open */
......
...@@ -266,6 +266,8 @@ ...@@ -266,6 +266,8 @@
#define RFE_ADDR_FILT_LO(x) (0x404 + (8 * (x))) #define RFE_ADDR_FILT_LO(x) (0x404 + (8 * (x)))
#define RFE_CTL (0x508) #define RFE_CTL (0x508)
#define RFE_CTL_TCP_UDP_COE_ BIT(12)
#define RFE_CTL_IP_COE_ BIT(11)
#define RFE_CTL_AB_ BIT(10) #define RFE_CTL_AB_ BIT(10)
#define RFE_CTL_AM_ BIT(9) #define RFE_CTL_AM_ BIT(9)
#define RFE_CTL_AU_ BIT(8) #define RFE_CTL_AU_ BIT(8)
...@@ -954,8 +956,7 @@ struct lan743x_tx { ...@@ -954,8 +956,7 @@ struct lan743x_tx {
struct napi_struct napi; struct napi_struct napi;
u32 frame_count; u32 frame_count;
u32 rqd_descriptors;
struct sk_buff *overflow_skb;
}; };
void lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx, void lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx,
...@@ -1110,7 +1111,7 @@ struct lan743x_tx_buffer_info { ...@@ -1110,7 +1111,7 @@ struct lan743x_tx_buffer_info {
unsigned int buffer_length; unsigned int buffer_length;
}; };
#define LAN743X_TX_RING_SIZE (50) #define LAN743X_TX_RING_SIZE (128)
/* OWN bit is set. ie, Descs are owned by RX DMAC */ /* OWN bit is set. ie, Descs are owned by RX DMAC */
#define RX_DESC_DATA0_OWN_ (0x00008000) #define RX_DESC_DATA0_OWN_ (0x00008000)
...@@ -1122,6 +1123,9 @@ struct lan743x_tx_buffer_info { ...@@ -1122,6 +1123,9 @@ struct lan743x_tx_buffer_info {
(((data0) & RX_DESC_DATA0_FRAME_LENGTH_MASK_) >> 16) (((data0) & RX_DESC_DATA0_FRAME_LENGTH_MASK_) >> 16)
#define RX_DESC_DATA0_EXT_ (0x00004000) #define RX_DESC_DATA0_EXT_ (0x00004000)
#define RX_DESC_DATA0_BUF_LENGTH_MASK_ (0x00003FFF) #define RX_DESC_DATA0_BUF_LENGTH_MASK_ (0x00003FFF)
#define RX_DESC_DATA1_STATUS_ICE_ (0x00020000)
#define RX_DESC_DATA1_STATUS_TCE_ (0x00010000)
#define RX_DESC_DATA1_STATUS_ICSM_ (0x00000001)
#define RX_DESC_DATA2_TS_NS_MASK_ (0x3FFFFFFF) #define RX_DESC_DATA2_TS_NS_MASK_ (0x3FFFFFFF)
#if ((NET_IP_ALIGN != 0) && (NET_IP_ALIGN != 2)) #if ((NET_IP_ALIGN != 0) && (NET_IP_ALIGN != 2))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment