hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/net/ethernet/sfc/farch.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /****************************************************************************
23 * Driver for Solarflare network controllers and boards
34 * Copyright 2005-2006 Fen Systems Ltd.
45 * Copyright 2006-2013 Solarflare Communications Inc.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published
8
- * by the Free Software Foundation, incorporated herein by reference.
96 */
107
118 #include <linux/bitops.h>
....@@ -18,6 +15,7 @@
1815 #include "net_driver.h"
1916 #include "bitfield.h"
2017 #include "efx.h"
18
+#include "rx_common.h"
2119 #include "nic.h"
2220 #include "farch_regs.h"
2321 #include "sriov.h"
....@@ -322,7 +320,7 @@
322320 unsigned write_ptr;
323321 unsigned old_write_count = tx_queue->write_count;
324322
325
- tx_queue->xmit_more_available = false;
323
+ tx_queue->xmit_pending = false;
326324 if (unlikely(tx_queue->write_count == tx_queue->insert_count))
327325 return;
328326
....@@ -374,6 +372,8 @@
374372 struct efx_nic *efx = tx_queue->efx;
375373 unsigned entries;
376374
375
+ tx_queue->type = ((tx_queue->label & 1) ? EFX_TXQ_TYPE_OUTER_CSUM : 0) |
376
+ ((tx_queue->label & 2) ? EFX_TXQ_TYPE_HIGHPRI : 0);
377377 entries = tx_queue->ptr_mask + 1;
378378 return efx_alloc_special_buffer(efx, &tx_queue->txd,
379379 entries * sizeof(efx_qword_t));
....@@ -381,7 +381,7 @@
381381
382382 void efx_farch_tx_init(struct efx_tx_queue *tx_queue)
383383 {
384
- int csum = tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD;
384
+ int csum = tx_queue->type & EFX_TXQ_TYPE_OUTER_CSUM;
385385 struct efx_nic *efx = tx_queue->efx;
386386 efx_oword_t reg;
387387
....@@ -397,7 +397,7 @@
397397 FRF_AZ_TX_DESCQ_EVQ_ID,
398398 tx_queue->channel->channel,
399399 FRF_AZ_TX_DESCQ_OWNER_ID, 0,
400
- FRF_AZ_TX_DESCQ_LABEL, tx_queue->queue,
400
+ FRF_AZ_TX_DESCQ_LABEL, tx_queue->label,
401401 FRF_AZ_TX_DESCQ_SIZE,
402402 __ffs(tx_queue->txd.entries),
403403 FRF_AZ_TX_DESCQ_TYPE, 0,
....@@ -411,10 +411,12 @@
411411
412412 EFX_POPULATE_OWORD_1(reg,
413413 FRF_BZ_TX_PACE,
414
- (tx_queue->queue & EFX_TXQ_TYPE_HIGHPRI) ?
414
+ (tx_queue->type & EFX_TXQ_TYPE_HIGHPRI) ?
415415 FFE_BZ_TX_PACE_OFF :
416416 FFE_BZ_TX_PACE_RESERVED);
417417 efx_writeo_table(efx, &reg, FR_BZ_TX_PACE_TBL, tx_queue->queue);
418
+
419
+ tx_queue->tso_version = 1;
418420 }
419421
420422 static void efx_farch_flush_tx_queue(struct efx_tx_queue *tx_queue)
....@@ -833,14 +835,14 @@
833835 /* Transmit completion */
834836 tx_ev_desc_ptr = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_DESC_PTR);
835837 tx_ev_q_label = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_Q_LABEL);
836
- tx_queue = efx_channel_get_tx_queue(
837
- channel, tx_ev_q_label % EFX_TXQ_TYPES);
838
+ tx_queue = channel->tx_queue +
839
+ (tx_ev_q_label % EFX_MAX_TXQ_PER_CHANNEL);
838840 efx_xmit_done(tx_queue, tx_ev_desc_ptr);
839841 } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_WQ_FF_FULL)) {
840842 /* Rewrite the FIFO write pointer */
841843 tx_ev_q_label = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_Q_LABEL);
842
- tx_queue = efx_channel_get_tx_queue(
843
- channel, tx_ev_q_label % EFX_TXQ_TYPES);
844
+ tx_queue = channel->tx_queue +
845
+ (tx_ev_q_label % EFX_MAX_TXQ_PER_CHANNEL);
844846
845847 netif_tx_lock(efx->net_dev);
846848 efx_farch_notify_tx_desc(tx_queue);
....@@ -865,13 +867,8 @@
865867 bool rx_ev_tcp_udp_chksum_err, rx_ev_eth_crc_err;
866868 bool rx_ev_frm_trunc, rx_ev_tobe_disc;
867869 bool rx_ev_other_err, rx_ev_pause_frm;
868
- bool rx_ev_hdr_type, rx_ev_mcast_pkt;
869
- unsigned rx_ev_pkt_type;
870870
871
- rx_ev_hdr_type = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_HDR_TYPE);
872
- rx_ev_mcast_pkt = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_MCAST_PKT);
873871 rx_ev_tobe_disc = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_TOBE_DISC);
874
- rx_ev_pkt_type = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_PKT_TYPE);
875872 rx_ev_buf_owner_id_err = EFX_QWORD_FIELD(*event,
876873 FSF_AZ_RX_EV_BUF_OWNER_ID_ERR);
877874 rx_ev_ip_hdr_chksum_err = EFX_QWORD_FIELD(*event,
....@@ -920,6 +917,8 @@
920917 rx_ev_tobe_disc ? " [TOBE_DISC]" : "",
921918 rx_ev_pause_frm ? " [PAUSE]" : "");
922919 }
920
+#else
921
+ (void) rx_ev_other_err;
923922 #endif
924923
925924 if (efx->net_dev->features & NETIF_F_RXALL)
....@@ -1040,10 +1039,10 @@
10401039 switch (rx_ev_hdr_type) {
10411040 case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP:
10421041 flags |= EFX_RX_PKT_TCP;
1043
- /* fall through */
1042
+ fallthrough;
10441043 case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP:
10451044 flags |= EFX_RX_PKT_CSUMMED;
1046
- /* fall through */
1045
+ fallthrough;
10471046 case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_OTHER:
10481047 case FSE_AZ_RX_EV_HDR_TYPE_OTHER:
10491048 break;
....@@ -1082,16 +1081,16 @@
10821081 efx_farch_handle_tx_flush_done(struct efx_nic *efx, efx_qword_t *event)
10831082 {
10841083 struct efx_tx_queue *tx_queue;
1084
+ struct efx_channel *channel;
10851085 int qid;
10861086
10871087 qid = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBDATA);
1088
- if (qid < EFX_TXQ_TYPES * (efx->n_tx_channels + efx->n_extra_tx_channels)) {
1089
- tx_queue = efx_get_tx_queue(efx, qid / EFX_TXQ_TYPES,
1090
- qid % EFX_TXQ_TYPES);
1091
- if (atomic_cmpxchg(&tx_queue->flush_outstanding, 1, 0)) {
1088
+ if (qid < EFX_MAX_TXQ_PER_CHANNEL * (efx->n_tx_channels + efx->n_extra_tx_channels)) {
1089
+ channel = efx_get_tx_channel(efx, qid / EFX_MAX_TXQ_PER_CHANNEL);
1090
+ tx_queue = channel->tx_queue + (qid % EFX_MAX_TXQ_PER_CHANNEL);
1091
+ if (atomic_cmpxchg(&tx_queue->flush_outstanding, 1, 0))
10921092 efx_farch_magic_event(tx_queue->channel,
10931093 EFX_CHANNEL_MAGIC_TX_DRAIN(tx_queue));
1094
- }
10951094 }
10961095 }
10971096
....@@ -1318,7 +1317,7 @@
13181317 if (efx->type->handle_global_event &&
13191318 efx->type->handle_global_event(channel, &event))
13201319 break;
1321
- /* else fall through */
1320
+ fallthrough;
13221321 default:
13231322 netif_err(channel->efx, hw, channel->efx->net_dev,
13241323 "channel %d unknown event type %d (data "
....@@ -1680,10 +1679,10 @@
16801679 * and the descriptor caches for those channels.
16811680 */
16821681 buftbl_min = ((efx->n_rx_channels * EFX_MAX_DMAQ_SIZE +
1683
- total_tx_channels * EFX_TXQ_TYPES * EFX_MAX_DMAQ_SIZE +
1682
+ total_tx_channels * EFX_MAX_TXQ_PER_CHANNEL * EFX_MAX_DMAQ_SIZE +
16841683 efx->n_channels * EFX_MAX_EVQ_SIZE)
16851684 * sizeof(efx_qword_t) / EFX_BUF_SIZE);
1686
- vi_count = max(efx->n_channels, total_tx_channels * EFX_TXQ_TYPES);
1685
+ vi_count = max(efx->n_channels, total_tx_channels * EFX_MAX_TXQ_PER_CHANNEL);
16871686
16881687 #ifdef CONFIG_SFC_SRIOV
16891688 if (efx->type->sriov_wanted) {
....@@ -2045,7 +2044,7 @@
20452044 EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT |
20462045 EFX_FILTER_MATCH_REM_HOST | EFX_FILTER_MATCH_REM_PORT):
20472046 is_full = true;
2048
- /* fall through */
2047
+ fallthrough;
20492048 case (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_IP_PROTO |
20502049 EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT): {
20512050 __be32 rhost, host1, host2;
....@@ -2096,7 +2095,7 @@
20962095
20972096 case EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_OUTER_VID:
20982097 is_full = true;
2099
- /* fall through */
2098
+ fallthrough;
21002099 case EFX_FILTER_MATCH_LOC_MAC:
21012100 spec->type = (is_full ? EFX_FARCH_FILTER_MAC_FULL :
21022101 EFX_FARCH_FILTER_MAC_WILD);
....@@ -2143,7 +2142,7 @@
21432142 case EFX_FARCH_FILTER_TCP_FULL:
21442143 case EFX_FARCH_FILTER_UDP_FULL:
21452144 is_full = true;
2146
- /* fall through */
2145
+ fallthrough;
21472146 case EFX_FARCH_FILTER_TCP_WILD:
21482147 case EFX_FARCH_FILTER_UDP_WILD: {
21492148 __be32 host1, host2;
....@@ -2187,7 +2186,7 @@
21872186
21882187 case EFX_FARCH_FILTER_MAC_FULL:
21892188 is_full = true;
2190
- /* fall through */
2189
+ fallthrough;
21912190 case EFX_FARCH_FILTER_MAC_WILD:
21922191 gen_spec->match_flags = EFX_FILTER_MATCH_LOC_MAC;
21932192 if (is_full)
....@@ -2594,7 +2593,6 @@
25942593 enum efx_farch_filter_table_id table_id;
25952594 struct efx_farch_filter_table *table;
25962595 unsigned int filter_idx;
2597
- struct efx_farch_filter_spec *spec;
25982596 int rc;
25992597
26002598 table_id = efx_farch_filter_id_table_id(filter_id);
....@@ -2606,7 +2604,6 @@
26062604 if (filter_idx >= table->size)
26072605 return -ENOENT;
26082606 down_write(&state->lock);
2609
- spec = &table->spec[filter_idx];
26102607
26112608 rc = efx_farch_filter_remove(efx, table, filter_idx, priority);
26122609 up_write(&state->lock);