LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Stathis Voukelatos <stathisv70@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	Stathis Voukelatos <stathis.voukelatos@linn.co.uk>,
	abrestic@chromium.org
Subject: Re: [PATCH] net: Linn Ethernet Packet Sniffer driver
Date: Sat, 24 Jan 2015 13:37:12 -0800	[thread overview]
Message-ID: <1422135432.18650.2.camel@perches.com> (raw)
In-Reply-To: <1422007621-13567-1-git-send-email-stathis.voukelatos@linn.co.uk>

On Fri, 2015-01-23 at 10:07 +0000, Stathis Voukelatos wrote:
> This patch adds support the Ethernet Packet Sniffer H/W module
> developed by Linn Products Ltd and found in the IMG Pistachio SoC.
> The module allows Ethernet packets to be parsed, matched against
> a user-defined pattern and timestamped. It sits between a 100M
> Ethernet MAC and PHY and is completely passive with respect to
> Ethernet frames.
[]
>  include/linux/pkt_sniffer.h                        |  89 +++++

Why should this file be here?
Why not in the drivers/net/pkt-sniffer directory?

> diff --git a/drivers/net/pkt-sniffer/backends/ether/channel.c b/drivers/net/pkt-sniffer/backends/ether/channel.c
[]
> +static int esnf_start(struct snf_chan *dev);

Be nice to rearrange the code to avoid the forward declarations.

> +static int esnf_stop(struct snf_chan *dev);
> +static int esnf_set_pattern(struct snf_chan *dev, const u8 *pattern, int count);
> +static int esnf_num_recs_avail(struct snf_chan *dev);
> +static int esnf_max_ptn_entries(struct snf_chan *dev);
> +static int esnf_max_match_bytes(struct snf_chan *dev);
> +static int validate_pattern(
> +			struct ether_snf_chan *ch,
> +			const u8 *buf,
> +			int count);

[]

> +static int validate_pattern(struct ether_snf_chan *ch, const u8 *buf, int count)
> +{

Maybe better as bool

> +	int i, complete, max_copy_bytes;
[]
> +	/* Check if the string was properly terminated
> +	 * and contained valid number of commands
> +	 */
> +	if (complete) {
> +		max_copy_bytes = ch->fifo_blk_words * 4;
> +		if (ts)
> +			max_copy_bytes -= 4;
> +		if ((copy_before + copy_after) > max_copy_bytes)
> +			return 0;
> +		ch->ts_present = ts;
> +		ch->nfb_before = copy_before;
> +		ch->nfb_after = copy_after;
> +		return 1;
> +	} else {
> +		return 0;
> +	}

	return complete;

[]

> +/* Interrupt thread function */
> +static irqreturn_t esnf_irq_thread(int irq, void *dev_id)
> +{
> +	struct platform_device *pdev = (struct platform_device *)dev_id;
> +	struct ether_snf *esnf = (struct ether_snf *)platform_get_drvdata(pdev);
> +	u32 irq_status;
> +
> +	if (unlikely(esnf->irq != irq))
> +		return IRQ_NONE;
> +
> +	irq_status = ioread32(esnf->regs + INTERRUPT_STATUS) &
> +				 ioread32(esnf->regs + INTERRUPT_ENABLE);
> +
> +	dev_dbg(&pdev->dev, "irq: 0x%08x\n", irq_status);
> +
> +	/* TX FIFO full */
> +	if (unlikely(irq_status & TX_FULL_IRQ_BIT))
> +		dev_notice(&pdev->dev, "TX FIFO full");

Missing terminating newlines
> +
> +	/* RX FIFO full */
> +	if (unlikely(irq_status & RX_FULL_IRQ_BIT))
> +		dev_notice(&pdev->dev, "RX FIFO full");
> +
> +	/* TX match data available */
> +	if (irq_status & TX_DATA_IRQ_BIT) {
> +		dev_dbg(&pdev->dev, "TX data");
> +		channel_data_available(&esnf->txc);
> +	}
> +
> +	/* RX match data available */
> +	if (irq_status & RX_DATA_IRQ_BIT) {
> +		dev_dbg(&pdev->dev, "RX data");
> +		channel_data_available(&esnf->rxc);
> +	}

> diff --git a/drivers/net/pkt-sniffer/core/nl.c b/drivers/net/pkt-sniffer/core/nl.c
[]
> +int snf_netlink_init(int id, struct snf_chan *dev, const char *name)
> +{
[]
> +	/* Allocate ops array and copy template data */
> +	nl->ops = kmalloc(sizeof(snf_ops_tmpl), GFP_KERNEL);
> +	if (!nl->ops) {
> +		ret = -ENOMEM;
> +		goto fail2;
> +	}
> +	memcpy(nl->ops, snf_ops_tmpl, sizeof(snf_ops_tmpl));

kmemdup




  parent reply	other threads:[~2015-01-25 21:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 10:07 Stathis Voukelatos
2015-01-23 10:21 ` Arnd Bergmann
2015-01-26 11:23   ` Stathis Voukelatos
2015-01-23 10:51 ` Mark Rutland
2015-01-26 10:16   ` Stathis Voukelatos
2015-01-27 10:53     ` Mark Rutland
2015-01-23 11:20 ` Daniel Borkmann
2015-01-26  9:49   ` Stathis Voukelatos
2015-01-26 10:10     ` Daniel Borkmann
2015-01-27 11:15       ` Stathis Voukelatos
2015-01-27 14:46         ` Daniel Borkmann
2015-01-27 17:22           ` Stathis Voukelatos
2015-01-23 18:12 ` James Hogan
2015-01-26 11:05   ` Stathis Voukelatos
2015-01-24 21:37 ` Joe Perches [this message]
2015-01-26 11:11   ` Stathis Voukelatos
2015-01-26 19:39     ` Joe Perches
2015-01-27  9:52       ` Stathis Voukelatos
2015-01-26 22:30 ` Florian Fainelli
2015-01-27 10:51   ` Stathis Voukelatos

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=1422135432.18650.2.camel@perches.com \
    --to=joe@perches.com \
    --cc=abrestic@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stathis.voukelatos@linn.co.uk \
    --cc=stathisv70@gmail.com \
    --subject='Re: [PATCH] net: Linn Ethernet Packet Sniffer driver' \
    /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

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).