From: Ben Hutchings <bhutchings@solarflare.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: netdev@vger.kernel.org, linux-net-drivers@solarflare.com
Subject: [PATCH 04/52] sfc: Use separate hardware TX queues to select checksum generation
Date: Mon, 1 Sep 2008 12:44:59 +0100 [thread overview]
Message-ID: <20080901114458.GX7908@solarflare.com> (raw)
In-Reply-To: <20080901111621.GT7908@solarflare.com>
Checksum generation is an attribute of our hardware TX queues, not TX
descriptors. We previously used a single queue and turned checksum
generation on or off as requested through ethtool. However, this can
result in regenerating checksums in raw packets that should not be
modified. We now create 2 hardware TX queues with checksum generation
on or off. They are presented to the net core as one queue since it
does not know how to select between them.
The self-test verifies that a bad checksum is unaltered on the queue
with checksum generation off.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/sfc/efx.c | 25 +++++++---------------
drivers/net/sfc/ethtool.c | 45 +----------------------------------------
drivers/net/sfc/falcon.c | 11 +++++----
drivers/net/sfc/net_driver.h | 21 ++++++++-----------
drivers/net/sfc/selftest.c | 11 ++++++++-
drivers/net/sfc/selftest.h | 4 +-
drivers/net/sfc/tx.c | 23 +++++++++++----------
7 files changed, 48 insertions(+), 92 deletions(-)
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 4253980..2a23005 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -923,22 +923,13 @@ static void efx_select_used(struct efx_nic *efx)
struct efx_rx_queue *rx_queue;
int i;
- /* TX queues. One per port per channel with TX capability
- * (more than one per port won't work on Linux, due to out
- * of order issues... but will be fine on Solaris)
- */
- tx_queue = &efx->tx_queue[0];
-
- /* Perform this for each channel with TX capabilities.
- * At the moment, we only support a single TX queue
- */
- tx_queue->used = 1;
- if ((!EFX_INT_MODE_USE_MSI(efx)) && separate_tx_and_rx_channels)
- tx_queue->channel = &efx->channel[1];
- else
- tx_queue->channel = &efx->channel[0];
- tx_queue->channel->used_flags |= EFX_USED_BY_TX;
- tx_queue++;
+ efx_for_each_tx_queue(tx_queue, efx) {
+ if (!EFX_INT_MODE_USE_MSI(efx) && separate_tx_and_rx_channels)
+ tx_queue->channel = &efx->channel[1];
+ else
+ tx_queue->channel = &efx->channel[0];
+ tx_queue->channel->used_flags |= EFX_USED_BY_TX;
+ }
/* RX queues. Each has a dedicated channel. */
for (i = 0; i < EFX_MAX_RX_QUEUES; i++) {
@@ -1881,7 +1872,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
channel->evqnum = i;
channel->work_pending = 0;
}
- for (i = 0; i < EFX_MAX_TX_QUEUES; i++) {
+ for (i = 0; i < EFX_TX_QUEUE_COUNT; i++) {
tx_queue = &efx->tx_queue[i];
tx_queue->efx = efx;
tx_queue->queue = i;
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index 8a15be6..ccd82f1 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -32,8 +32,6 @@ const char *efx_loopback_mode_names[] = {
[LOOPBACK_NETWORK] = "NETWORK",
};
-static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable);
-
struct ethtool_string {
char name[ETH_GSTRING_LEN];
};
@@ -442,45 +440,6 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
}
}
-static int efx_ethtool_set_tso(struct net_device *net_dev, u32 enable)
-{
- int rc;
-
- /* Our TSO requires TX checksumming, so force TX checksumming
- * on when TSO is enabled.
- */
- if (enable) {
- rc = efx_ethtool_set_tx_csum(net_dev, 1);
- if (rc)
- return rc;
- }
-
- return ethtool_op_set_tso(net_dev, enable);
-}
-
-static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable)
-{
- struct efx_nic *efx = netdev_priv(net_dev);
- int rc;
-
- rc = ethtool_op_set_tx_csum(net_dev, enable);
- if (rc)
- return rc;
-
- efx_flush_queues(efx);
-
- /* Our TSO requires TX checksumming, so disable TSO when
- * checksumming is disabled
- */
- if (!enable) {
- rc = efx_ethtool_set_tso(net_dev, 0);
- if (rc)
- return rc;
- }
-
- return 0;
-}
-
static int efx_ethtool_set_rx_csum(struct net_device *net_dev, u32 enable)
{
struct efx_nic *efx = netdev_priv(net_dev);
@@ -701,11 +660,11 @@ struct ethtool_ops efx_ethtool_ops = {
.get_rx_csum = efx_ethtool_get_rx_csum,
.set_rx_csum = efx_ethtool_set_rx_csum,
.get_tx_csum = ethtool_op_get_tx_csum,
- .set_tx_csum = efx_ethtool_set_tx_csum,
+ .set_tx_csum = ethtool_op_set_tx_csum,
.get_sg = ethtool_op_get_sg,
.set_sg = ethtool_op_set_sg,
.get_tso = ethtool_op_get_tso,
- .set_tso = efx_ethtool_set_tso,
+ .set_tso = ethtool_op_set_tso,
.get_flags = ethtool_op_get_flags,
.set_flags = ethtool_op_set_flags,
.self_test_count = efx_ethtool_self_test_count,
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index c7aa2f6..b73f1ea 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -474,9 +474,9 @@ int falcon_init_tx(struct efx_tx_queue *tx_queue)
TX_NON_IP_DROP_DIS_B0, 1);
if (falcon_rev(efx) >= FALCON_REV_B0) {
- int csum = !(efx->net_dev->features & NETIF_F_IP_CSUM);
- EFX_SET_OWORD_FIELD(tx_desc_ptr, TX_IP_CHKSM_DIS_B0, csum);
- EFX_SET_OWORD_FIELD(tx_desc_ptr, TX_TCP_CHKSM_DIS_B0, csum);
+ int csum = tx_queue->queue == EFX_TX_QUEUE_OFFLOAD_CSUM;
+ EFX_SET_OWORD_FIELD(tx_desc_ptr, TX_IP_CHKSM_DIS_B0, !csum);
+ EFX_SET_OWORD_FIELD(tx_desc_ptr, TX_TCP_CHKSM_DIS_B0, !csum);
}
falcon_write_table(efx, &tx_desc_ptr, efx->type->txd_ptr_tbl_base,
@@ -485,10 +485,11 @@ int falcon_init_tx(struct efx_tx_queue *tx_queue)
if (falcon_rev(efx) < FALCON_REV_B0) {
efx_oword_t reg;
- BUG_ON(tx_queue->queue >= 128); /* HW limit */
+ /* Only 128 bits in this register */
+ BUILD_BUG_ON(EFX_TX_QUEUE_COUNT >= 128);
falcon_read(efx, ®, TX_CHKSM_CFG_REG_KER_A1);
- if (efx->net_dev->features & NETIF_F_IP_CSUM)
+ if (tx_queue->queue == EFX_TX_QUEUE_OFFLOAD_CSUM)
clear_bit_le(tx_queue->queue, (void *)®);
else
set_bit_le(tx_queue->queue, (void *)®);
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 628f25e..f539e2e 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -88,9 +88,12 @@ do {if (net_ratelimit()) EFX_LOG(efx, fmt, ##args); } while (0)
**************************************************************************/
#define EFX_MAX_CHANNELS 32
-#define EFX_MAX_TX_QUEUES 1
#define EFX_MAX_RX_QUEUES EFX_MAX_CHANNELS
+#define EFX_TX_QUEUE_OFFLOAD_CSUM 0
+#define EFX_TX_QUEUE_NO_CSUM 1
+#define EFX_TX_QUEUE_COUNT 2
+
/**
* struct efx_special_buffer - An Efx special buffer
* @addr: CPU base address of the buffer
@@ -156,7 +159,6 @@ struct efx_tx_buffer {
*
* @efx: The associated Efx NIC
* @queue: DMA queue number
- * @used: Queue is used by net driver
* @channel: The associated channel
* @buffer: The software buffer ring
* @txd: The hardware descriptor ring
@@ -188,7 +190,6 @@ struct efx_tx_queue {
/* Members which don't change on the fast path */
struct efx_nic *efx ____cacheline_aligned_in_smp;
int queue;
- int used;
struct efx_channel *channel;
struct efx_nic *nic;
struct efx_tx_buffer *buffer;
@@ -699,7 +700,7 @@ struct efx_nic {
enum nic_state state;
enum reset_type reset_pending;
- struct efx_tx_queue tx_queue[EFX_MAX_TX_QUEUES];
+ struct efx_tx_queue tx_queue[EFX_TX_QUEUE_COUNT];
struct efx_rx_queue rx_queue[EFX_MAX_RX_QUEUES];
struct efx_channel channel[EFX_MAX_CHANNELS];
@@ -840,19 +841,15 @@ struct efx_nic_type {
/* Iterate over all used TX queues */
#define efx_for_each_tx_queue(_tx_queue, _efx) \
for (_tx_queue = &_efx->tx_queue[0]; \
- _tx_queue < &_efx->tx_queue[EFX_MAX_TX_QUEUES]; \
- _tx_queue++) \
- if (!_tx_queue->used) \
- continue; \
- else
+ _tx_queue < &_efx->tx_queue[EFX_TX_QUEUE_COUNT]; \
+ _tx_queue++)
/* Iterate over all TX queues belonging to a channel */
#define efx_for_each_channel_tx_queue(_tx_queue, _channel) \
for (_tx_queue = &_channel->efx->tx_queue[0]; \
- _tx_queue < &_channel->efx->tx_queue[EFX_MAX_TX_QUEUES]; \
+ _tx_queue < &_channel->efx->tx_queue[EFX_TX_QUEUE_COUNT]; \
_tx_queue++) \
- if ((!_tx_queue->used) || \
- (_tx_queue->channel != _channel)) \
+ if (_tx_queue->channel != _channel) \
continue; \
else
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index 3b2de9f..0a47786 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -63,6 +63,10 @@ struct efx_selftest_state {
int flush;
int packet_count;
struct sk_buff **skbs;
+
+ /* Checksums are being offloaded */
+ int offload_csum;
+
atomic_t rx_good;
atomic_t rx_bad;
struct efx_loopback_payload payload;
@@ -292,8 +296,9 @@ void efx_loopback_rx_packet(struct efx_nic *efx,
received = (struct efx_loopback_payload *) buf_ptr;
received->ip.saddr = payload->ip.saddr;
- received->ip.check = payload->ip.check;
-
+ if (state->offload_csum)
+ received->ip.check = payload->ip.check;
+
/* Check that header exists */
if (pkt_len < sizeof(received->header)) {
EFX_ERR(efx, "saw runt RX packet (length %d) in %s loopback "
@@ -634,6 +639,8 @@ static int efx_test_loopbacks(struct efx_nic *efx,
/* Test every TX queue */
efx_for_each_tx_queue(tx_queue, efx) {
+ state->offload_csum = (tx_queue->queue ==
+ EFX_TX_QUEUE_OFFLOAD_CSUM);
rc |= efx_test_loopback(tx_queue,
&tests->loopback[mode]);
if (rc)
diff --git a/drivers/net/sfc/selftest.h b/drivers/net/sfc/selftest.h
index f6999c2..cd59f00 100644
--- a/drivers/net/sfc/selftest.h
+++ b/drivers/net/sfc/selftest.h
@@ -18,8 +18,8 @@
*/
struct efx_loopback_self_tests {
- int tx_sent[EFX_MAX_TX_QUEUES];
- int tx_done[EFX_MAX_TX_QUEUES];
+ int tx_sent[EFX_TX_QUEUE_COUNT];
+ int tx_done[EFX_TX_QUEUE_COUNT];
int rx_good;
int rx_bad;
};
diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c
index 2a09101..e5e0bab 100644
--- a/drivers/net/sfc/tx.c
+++ b/drivers/net/sfc/tx.c
@@ -368,7 +368,14 @@ inline int efx_xmit(struct efx_nic *efx,
int efx_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
{
struct efx_nic *efx = netdev_priv(net_dev);
- return efx_xmit(efx, &efx->tx_queue[0], skb);
+ struct efx_tx_queue *tx_queue;
+
+ if (likely(skb->ip_summed == CHECKSUM_PARTIAL))
+ tx_queue = &efx->tx_queue[EFX_TX_QUEUE_OFFLOAD_CSUM];
+ else
+ tx_queue = &efx->tx_queue[EFX_TX_QUEUE_NO_CSUM];
+
+ return efx_xmit(efx, tx_queue, skb);
}
void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index)
@@ -412,26 +419,21 @@ int efx_probe_tx_queue(struct efx_tx_queue *tx_queue)
/* Allocate software ring */
txq_size = (efx->type->txd_ring_mask + 1) * sizeof(*tx_queue->buffer);
tx_queue->buffer = kzalloc(txq_size, GFP_KERNEL);
- if (!tx_queue->buffer) {
- rc = -ENOMEM;
- goto fail1;
- }
+ if (!tx_queue->buffer)
+ return -ENOMEM;
for (i = 0; i <= efx->type->txd_ring_mask; ++i)
tx_queue->buffer[i].continuation = 1;
/* Allocate hardware ring */
rc = falcon_probe_tx(tx_queue);
if (rc)
- goto fail2;
+ goto fail;
return 0;
- fail2:
+ fail:
kfree(tx_queue->buffer);
tx_queue->buffer = NULL;
- fail1:
- tx_queue->used = 0;
-
return rc;
}
@@ -494,7 +496,6 @@ void efx_remove_tx_queue(struct efx_tx_queue *tx_queue)
kfree(tx_queue->buffer);
tx_queue->buffer = NULL;
- tx_queue->used = 0;
}
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2008-09-01 11:45 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-01 11:16 [PATCH 00/52] sfc: Changes for 2.6.28 Ben Hutchings
2008-09-01 11:43 ` [PATCH 01/52] sfc: Replace net_dev->priv with netdev_priv(net_dev) Ben Hutchings
2008-09-01 11:43 ` [PATCH 02/52] sfc: Change first parameter type of {set,clear}_bit_le() to unsigned Ben Hutchings
2008-09-01 11:44 ` [PATCH 03/52] sfc: Remove unused field efx_channel::reset_work Ben Hutchings
2008-09-01 11:44 ` Ben Hutchings [this message]
2008-09-01 11:45 ` [PATCH 05/52] sfc: Avoid mangling error codes in efx_test_loopback() Ben Hutchings
2008-09-01 11:45 ` [PATCH 06/52] sfc: Reduce delays in SFE4001 initialisation Ben Hutchings
2008-09-01 11:46 ` [PATCH 07/52] sfc: Remove mistaken hardware workaround Ben Hutchings
2008-09-01 11:46 ` [PATCH 08/52] sfc: XMAC statistics fix-ups Ben Hutchings
2008-09-01 11:46 ` [PATCH 09/52] sfc: Remove inclusion of workarounds.h from efx.c Ben Hutchings
2008-09-01 11:46 ` [PATCH 10/52] sfc: Reverse the XOFF/XON pause frame control fifo thresholds Ben Hutchings
2008-09-01 11:46 ` [PATCH 11/52] sfc: Reduce log level for XGXS lane status Ben Hutchings
2008-09-01 11:46 ` [PATCH 12/52] sfc: Self-test reporting cleanup Ben Hutchings
2008-09-01 11:46 ` [PATCH 13/52] sfc: Speed up loopback self-test Ben Hutchings
2008-09-01 11:46 ` [PATCH 14/52] sfc: Don't leak PCI DMA maps in the TSO code when the queue fills up Ben Hutchings
2008-09-01 11:46 ` [PATCH 15/52] sfc: Use pci_map_single() to map the skb header when doing TSO Ben Hutchings
2008-09-01 11:46 ` [PATCH 16/52] sfc: Reduce the size of struct efx_tx_buffer Ben Hutchings
2008-09-01 11:46 ` [PATCH 17/52] sfc: Use explicit bool for boolean variables, parameters and return values Ben Hutchings
2008-09-01 11:46 ` [PATCH 18/52] sfc: Set net_device::vlan_features appropriately Ben Hutchings
2008-09-01 11:47 ` [PATCH 19/52] sfc: Cleaned up struct tso_state fields Ben Hutchings
2008-09-01 11:47 ` [PATCH 20/52] sfc: Removed forced inlining of long functions Ben Hutchings
2008-09-01 11:47 ` [PATCH 21/52] sfc: Export boot configuration in EEPROM through ethtool Ben Hutchings
2008-09-01 11:47 ` [PATCH 22/52] sfc: Move CPU counting for RSS into a separate function, efx_wanted_rx_queues() Ben Hutchings
2008-09-01 11:47 ` [PATCH 23/52] sfc: Remove efx_channel::has_interrupt Ben Hutchings
2008-09-01 11:47 ` [PATCH 24/52] sfc: Cleanup RX queue information Ben Hutchings
2008-09-01 11:47 ` [PATCH 25/52] sfc: Remove initialisation of RX_FILTER_CTL_REG.NUM_KER Ben Hutchings
2008-09-01 11:47 ` [PATCH 26/52] sfc: Make efx_for_each_channel_rx_queue() more efficient Ben Hutchings
2008-09-01 11:48 ` [PATCH 27/52] sfc: Remove efx_channel::evqnum field Ben Hutchings
2008-09-01 11:48 ` [PATCH 28/52] sfc: Cleanup RX event processing Ben Hutchings
2008-09-01 11:48 ` [PATCH 29/52] sfc: Implement get_sset_count, replacing get_stats_count and self_test_count Ben Hutchings
2008-09-01 11:48 ` [PATCH 30/52] sfc: Make PHY flash mode a device attribute, not a module parameter Ben Hutchings
2008-09-01 11:48 ` [PATCH 31/52] sfc: Do not call netif_{stop,wake}_queue() before register_netdev Ben Hutchings
2008-09-01 11:48 ` [PATCH 32/52] sfc: Enable TSO for 802.1q VLAN devices Ben Hutchings
2008-09-01 11:48 ` [PATCH 33/52] sfc: Remove efx_nic_dummy_op_int() as redundant with efx_port_dummy_op_int() Ben Hutchings
2008-09-01 11:48 ` [PATCH 34/52] sfc: Remove remnants of multi-port abstraction for MAC registers Ben Hutchings
2008-09-01 11:48 ` [PATCH 35/52] sfc: Remove some unreachable error paths Ben Hutchings
2008-09-01 11:48 ` [PATCH 36/52] sfc: Cleanup reset code Ben Hutchings
2008-09-01 11:48 ` [PATCH 37/52] sfc: Rework the bitfield header so that we can identify fields by bit number Ben Hutchings
2008-09-01 11:49 ` [PATCH 38/52] sfc: Extend self-tests Ben Hutchings
2008-09-01 11:49 ` [PATCH 39/52] sfc: Remove the STATE_RESETTING flag Ben Hutchings
2008-09-01 11:49 ` [PATCH 40/52] sfc: Rework efx_set_multicast_hash() Ben Hutchings
2008-09-03 13:54 ` Jeff Garzik
2008-09-01 11:49 ` [PATCH 42/52] sfc: Fix memory BAR release call on error path Ben Hutchings
2008-09-01 11:49 ` [PATCH 43/52] sfc: Remove workaround for old firmware bug Ben Hutchings
2008-09-01 11:49 ` [PATCH 44/52] sfc: Serialise tenxpress_special_reset() with statistics fetches Ben Hutchings
2008-09-01 11:49 ` [PATCH 45/52] sfc: Don't use EFX_OWORD_FIELD on an event (64-bit, quad-word) Ben Hutchings
2008-09-01 11:49 ` [PATCH 46/52] sfc: Make queue flushes more reliable Ben Hutchings
2008-09-01 11:49 ` [PATCH 47/52] sfc: Don't include net_driver.h from falcon_io.h Ben Hutchings
2008-09-01 11:50 ` [PATCH 48/52] sfc: Stop generating bogus events in tenxpress_check_hw() Ben Hutchings
2008-09-01 11:50 ` [PATCH 49/52] sfc: Insert read memory barrier after checking MAC statistics flag Ben Hutchings
2008-09-01 11:50 ` [PATCH 50/52] sfc: Disable interrupts after a fatal interrupt occurs until reset Ben Hutchings
2008-09-01 11:50 ` [PATCH 51/52] sfc: Remove obsolete comment about PCI modes Ben Hutchings
2008-09-01 11:50 ` [PATCH 52/52] sfc: Use CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS where appropriate Ben Hutchings
2008-09-03 14:07 ` [PATCH 41/52] sfc: Add check for memory allocation failure in falcon_probe_nic() Ben Hutchings
2008-09-13 19:29 ` Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080901114458.GX7908@solarflare.com \
--to=bhutchings@solarflare.com \
--cc=jgarzik@pobox.com \
--cc=linux-net-drivers@solarflare.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).