From: David Miller <davem@davemloft.net>
To: noamc@ezchip.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexey.Brodkin@synopsys.com, vgupta@synopsys.com,
giladb@ezchip.com, cmetcalf@ezchip.com, talz@ezchip.com
Subject: Re: [PATCH v2] NET: Add ezchip ethernet driver
Date: Thu, 11 Jun 2015 15:43:06 -0700 (PDT) [thread overview]
Message-ID: <20150611.154306.1641662434579350039.davem@davemloft.net> (raw)
In-Reply-To: <1434011629-31257-1-git-send-email-noamc@ezchip.com>
From: Noam Camus <noamc@ezchip.com>
Date: Thu, 11 Jun 2015 11:33:49 +0300
> +#define NPS_ENET_INT_MASK (sizeof(u32) - 1)
> +#define NPS_ENET_INT_OFFSET 2
> +#define NPS_ENET_WORDS_NUM(length) ((length + NPS_ENET_INT_MASK) >> 2)
This is a bit obfuscating in my opinion.
First of all "NPS_ENET_INT_OFFSET" is not an "offset", which you would
add or subtract from a value, but rather it is a "shift". All of
the uses would look clearer as "X / sizeof(u32)" rather than the
"X >> NPS_ENET_INET_OFFSET".
Same for NPS_ENET_WORDS_NUM(), this is simply "DIV_ROUND_UP(x, sizeof_u32))"
which is much more easy to understand.
And I would just say "sizeof(u32) - 1" outright for the mask as well.
So basically what I'm saying is that these macros make the code harder
to read and understand rather than making it easier.
> +
> + /* to accommodate word-unaligned address of "reg"
> + * we have to do memcpy() instead of simple "="
> + */
> + memcpy(reg, &buf, sizeof(buf));
This is not guaranteed to work. 'ret' is a "u32 *" type therefore the
compiler is allowed to assume the pointer is properly aligned and
therefore emit a 32-bit load/store sequence inline for the memcpy()
call.
Which means all of this unaligned handling code is going to accomplish
nothing at all. The code will still make unaligned accesses.
> + netif_rx(skb);
Please implement proper NAPI support for your driver so that receive
packets are processed via the ->poll() handler in software interrupt
context rather than via netif_rx() in hardware interrupt context.
> +static void nps_enet_tx_irq_handler(struct net_device *netdev,
> + struct nps_enet_tx_ctl tx_ctrl)
> +{
Likewise for TX completion handling.
> +static struct net_device_stats *nps_enet_get_stats(struct net_device *ndev)
> +{
> + return &ndev->stats;
> +}
If this is all that your get_stats() method does, you can leave it unspecified
in nps_netdev_ops, and the core code will do the right thing by default.
prev parent reply other threads:[~2015-06-11 22:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 12:44 [PATCH] NET: Add ezchip ethernet driver Noam Camus
2015-06-09 14:11 ` Alexey Brodkin
2015-06-10 7:54 ` Paul Bolle
2015-06-11 8:33 ` [PATCH v2] " Noam Camus
2015-06-11 17:41 ` [PATCH v3] " Noam Camus
2015-06-14 6:26 ` [PATCH v4] " Noam Camus
2015-06-14 20:25 ` Florian Fainelli
2015-06-16 14:35 ` [PATCH v5] " Noam Camus
2015-06-21 16:22 ` David Miller
2015-06-22 14:52 ` Noam Camus
2015-06-22 17:45 ` Mahesh Bandewar
2015-06-22 23:47 ` Paul Gortmaker
2015-06-23 6:05 ` Noam Camus
2015-06-23 7:31 ` David Miller
2015-06-22 20:51 ` [PATCH v6] " Noam Camus
2015-06-22 21:04 ` Rami Rosen
2015-06-23 8:43 ` [PATCH v7] " Noam Camus
2015-06-23 14:17 ` David Miller
2015-06-24 3:40 ` Paul Gortmaker
2015-06-11 22:43 ` David Miller [this message]
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=20150611.154306.1641662434579350039.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=Alexey.Brodkin@synopsys.com \
--cc=cmetcalf@ezchip.com \
--cc=giladb@ezchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=noamc@ezchip.com \
--cc=talz@ezchip.com \
--cc=vgupta@synopsys.com \
/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).