From: Andrew Lunn <andrew@lunn.ch>
To: John Crispin <john@phrozen.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
qsdk-review@qca.qualcomm.com
Subject: Re: [PATCH 2/3] net-next: dsa: add Qualcomm tag RX/TX handler
Date: Mon, 12 Sep 2016 14:26:58 +0200 [thread overview]
Message-ID: <20160912122658.GA17533@lunn.ch> (raw)
In-Reply-To: <1473669337-21221-3-git-send-email-john@phrozen.org>
Hi John
> +
> +static inline int reg_to_port(int reg)
> +{
> + if (reg < 5)
> + return reg + 1;
> +
> + return -1;
> +}
> +
> +static inline int port_to_reg(int port)
> +{
> + if (port >= 1 && port <= 6)
> + return port - 1;
> +
> + return -1;
> +}
No need for inline, leave the compiler to decide.
> +
> +static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev)
> +{
> + struct dsa_slave_priv *p = netdev_priv(dev);
> + u16 *phdr, hdr;
> +
> + dev->stats.tx_packets++;
> + dev->stats.tx_bytes += skb->len;
> +
> + if (skb_cow_head(skb, 0) < 0)
> + goto out_free;
> +
> + skb_push(skb, QCA_HDR_LEN);
> +
> + memmove(skb->data, skb->data + QCA_HDR_LEN, 2 * ETH_ALEN);
> + phdr = (u16 *)(skb->data + 2 * ETH_ALEN);
> +
> + /* Set the version field, and set destination port information */
> + hdr = QCA_HDR_VERSION << QCA_HDR_XMIT_VERSION_S |
> + QCA_HDR_XMIT_FROM_CPU |
> + 1 << reg_to_port(p->port);
> +
> + *phdr = htons(hdr);
> +
> + //skb->dev = p->parent->dst->master_netdev;
> + //dev_queue_xmit(skb);
No commented out code please.
> +
> + return skb;
> +
> +out_free:
> + kfree_skb(skb);
> + return NULL;
> +}
> +
> +static int qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
> + struct packet_type *pt, struct net_device *orig_dev)
> +{
> + struct dsa_switch_tree *dst = dev->dsa_ptr;
> + struct dsa_switch *ds;
> + u8 ver;
> + int port, phy;
> + __be16 *phdr, hdr;
> +
> + if (unlikely(!dst))
> + goto out_drop;
> +
> + skb = skb_unshare(skb, GFP_ATOMIC);
> + if (!skb)
> + goto out;
> +
> + if (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN)))
> + goto out_drop;
> +
> + /* Ethernet is added by the switch between src addr and Ethertype
'Ethernet' seems to be the wrong word here.
> +
> + /* Get source port information */
> + port = (hdr & QCA_HDR_RECV_SOURCE_PORT_MASK);
> + phy = port_to_reg(port);
> + if (unlikely(phy < 0) || !ds->ports[phy].netdev)
> + goto out_drop;
Could you use a different variable name than phy. phy has a well known
meaning, and this usage is not it.
Otherwise, this looks good.
Andrew
next prev parent reply other threads:[~2016-09-12 12:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-12 8:35 [PATCH 0/3] net-next: dsa: add QCA8K support John Crispin
2016-09-12 8:35 ` [PATCH 1/3] Documentation: devicetree: add qca8k binding John Crispin
2016-09-12 11:53 ` Sergei Shtylyov
2016-09-12 8:35 ` [PATCH 2/3] net-next: dsa: add Qualcomm tag RX/TX handler John Crispin
2016-09-12 12:26 ` Andrew Lunn [this message]
2016-09-12 8:35 ` [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family John Crispin
2016-09-12 13:16 ` Andrew Lunn
2016-09-12 22:52 ` Andrew Lunn
2016-09-13 0:40 ` Andrew Lunn
2016-09-13 8:04 ` John Crispin
2016-09-13 15:59 ` Andrew Lunn
2016-09-13 17:09 ` Florian Fainelli
2016-09-13 18:07 ` John Crispin
2016-09-13 18:11 ` Florian Fainelli
2016-09-13 1:23 ` Andrew Lunn
2016-09-13 9:40 ` John Crispin
2016-09-13 13:14 ` Andrew Lunn
2016-09-13 17:11 ` Vivien Didelot
2016-09-13 19:07 ` Andrew Lunn
2016-09-13 19:10 ` John Crispin
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=20160912122658.GA17533@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=john@phrozen.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=qsdk-review@qca.qualcomm.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).