From: Shannon Nelson <snelson@pensando.io>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH v2 net-next 14/19] ionic: Add Tx and Rx handling
Date: Mon, 1 Jul 2019 11:17:08 -0700 [thread overview]
Message-ID: <b8fffe6f-e4c8-1412-1194-0ed65c27989f@pensando.io> (raw)
In-Reply-To: <20190629115723.5ae777bc@cakuba.netronome.com>
On 6/29/19 11:57 AM, Jakub Kicinski wrote:
> On Fri, 28 Jun 2019 14:39:29 -0700, Shannon Nelson wrote:
>> +static int ionic_tx(struct queue *q, struct sk_buff *skb)
>> +{
>> + struct tx_stats *stats = q_to_tx_stats(q);
>> + int err;
>> +
>> + if (skb->ip_summed == CHECKSUM_PARTIAL)
>> + err = ionic_tx_calc_csum(q, skb);
>> + else
>> + err = ionic_tx_calc_no_csum(q, skb);
>> + if (err)
>> + return err;
>> +
>> + err = ionic_tx_skb_frags(q, skb);
>> + if (err)
>> + return err;
>> +
>> + skb_tx_timestamp(skb);
>> + stats->pkts++;
>> + stats->bytes += skb->len;
> Presumably this is 64bit so you should use
> u64_stats_update_begin()
> u64_stats_update_end()
> around it (and all other stats).
Since the device won't work in a 32-bit arch and I have the the Kconfig
set to depend on 64BIT, I wasn't sure I needed to bother with the extra
syntactic sugar.
>> +
>> + ionic_txq_post(q, !netdev_xmit_more(), ionic_tx_clean, skb);
>> +
>> + return 0;
>> +}
>> +
>> +static int ionic_tx_descs_needed(struct queue *q, struct sk_buff *skb)
>> +{
>> + struct tx_stats *stats = q_to_tx_stats(q);
>> + int err;
>> +
>> + /* If TSO, need roundup(skb->len/mss) descs */
>> + if (skb_is_gso(skb))
>> + return (skb->len / skb_shinfo(skb)->gso_size) + 1;
>> +
>> + /* If non-TSO, just need 1 desc and nr_frags sg elems */
>> + if (skb_shinfo(skb)->nr_frags <= IONIC_TX_MAX_SG_ELEMS)
>> + return 1;
>> +
>> + /* Too many frags, so linearize */
>> + err = skb_linearize(skb);
>> + if (err)
>> + return err;
>> +
>> + stats->linearize++;
>> +
>> + /* Need 1 desc and zero sg elems */
>> + return 1;
>> +}
>> +
>> +netdev_tx_t ionic_start_xmit(struct sk_buff *skb, struct net_device *netdev)
>> +{
>> + u16 queue_index = skb_get_queue_mapping(skb);
>> + struct lif *lif = netdev_priv(netdev);
>> + struct queue *q;
>> + int ndescs;
>> + int err;
>> +
>> + if (unlikely(!test_bit(LIF_UP, lif->state))) {
>> + dev_kfree_skb(skb);
>> + return NETDEV_TX_OK;
>> + }
>> +
>> + if (likely(lif_to_txqcq(lif, queue_index)))
>> + q = lif_to_txq(lif, queue_index);
>> + else
>> + q = lif_to_txq(lif, 0);
>> +
>> + ndescs = ionic_tx_descs_needed(q, skb);
>> + if (ndescs < 0)
>> + goto err_out_drop;
>> +
>> + if (!ionic_q_has_space(q, ndescs)) {
>> + netif_stop_subqueue(netdev, queue_index);
>> + q->stop++;
>> +
>> + /* Might race with ionic_tx_clean, check again */
>> + smp_rmb();
>> + if (ionic_q_has_space(q, ndescs)) {
>> + netif_wake_subqueue(netdev, queue_index);
>> + q->wake++;
>> + } else {
>> + return NETDEV_TX_BUSY;
> This should never really happen..
Couldn't we have an Rx interrupt and a call to ionic_tx_clean() in the
middle of this?
>
>> + }
>> + }
>> +
>> + if (skb_is_gso(skb))
>> + err = ionic_tx_tso(q, skb);
>> + else
>> + err = ionic_tx(q, skb);
>> +
>> + if (err)
>> + goto err_out_drop;
> .. at this point if you can't guarantee fitting biggest possible frame
> in, you have to stop the ring.
Yep, that would work.
Thanks,
sln
next prev parent reply other threads:[~2019-07-01 18:17 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 21:39 [PATCH v2 net-next 00/19] Add ionic driver Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 01/19] ionic: Add basic framework for IONIC Network device driver Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 02/19] ionic: Add hardware init and device commands Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 03/19] ionic: Add port management commands Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 04/19] ionic: Add basic lif support Shannon Nelson
2019-06-29 18:45 ` Jakub Kicinski
2019-07-01 18:00 ` Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 05/19] ionic: Add interrupts and doorbells Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 06/19] ionic: Add basic adminq support Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 07/19] ionic: Add adminq action Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 08/19] ionic: Add notifyq support Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 09/19] ionic: Add the basic NDO callbacks for netdev support Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 10/19] ionic: Add management of rx filters Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 11/19] ionic: Add Rx filter and rx_mode ndo support Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 12/19] ionic: Add async link status check and basic stats Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 13/19] ionic: Add initial ethtool support Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 14/19] ionic: Add Tx and Rx handling Shannon Nelson
2019-06-29 18:57 ` Jakub Kicinski
2019-07-01 18:17 ` Shannon Nelson [this message]
2019-06-28 21:39 ` [PATCH v2 net-next 15/19] ionic: Add netdev-event handling Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 16/19] ionic: Add driver stats Shannon Nelson
2019-06-29 18:53 ` Jakub Kicinski
2019-07-01 18:06 ` Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 17/19] ionic: Add RSS support Shannon Nelson
2019-06-29 18:48 ` Jakub Kicinski
2019-07-01 18:03 ` Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 18/19] ionic: Add coalesce and other features Shannon Nelson
2019-06-28 21:39 ` [PATCH v2 net-next 19/19] ionic: Add basic devlink interface Shannon Nelson
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=b8fffe6f-e4c8-1412-1194-0ed65c27989f@pensando.io \
--to=snelson@pensando.io \
--cc=jakub.kicinski@netronome.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