Skip to contentSkip to conversation

gianfar v4: implement nfc

PATCH In review Sebastian Pöhn 2 participants 2 messages Jun 17, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gianfar v4: implement nfc

This patch adds all missing functionalities for nfc except GRXFH. There is so much code because hardware has not a TCAM. Further hardware rule space is very limited. So I had to extensively use
optimization features. Both reasons lead to the necessity to hold all
online flows in a linked-list.

Change-log:
# Migrated all printks to netdev_<level>
# Added check for ring_cookie > num_rx_queues
# Some style and spelling corrections

Made against net-next including Joe Perches's 59deab26c1974b29b7f501e0ace0673d5acadae1 commit.

---

 drivers/net/gianfar.c         |   10 +-
 drivers/net/gianfar.h         |   53 +++
 drivers/net/gianfar_ethtool.c |  956 ++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 1015 insertions(+), 4 deletions(-)
drivers/net/gianfar.c +7 -3
index 0c74832..def7f7e 100644
@@ -657,6 +657,11 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
 	priv->num_rx_queues = num_rx_qs;
 	priv->num_grps = 0x0;
 
+	/* Init Rx queue filer rule set linked list*/
+	INIT_LIST_HEAD(&priv->rx_list.list);
+	priv->rx_list.count = 0;
+	mutex_init(&priv->rx_queue_access);
+
 	model = of_get_property(np, "model", NULL);
 
 	for (i = 0; i < MAXGROUPS; i++)
@@ -1150,9 +1155,8 @@ static int gfar_probe(struct platform_device *ofdev)
 		priv->rx_queue[i]->rxic = DEFAULT_RXIC;
 	}
 
-	/* enable filer if using multiple RX queues*/
-	if(priv->num_rx_queues > 1)
-		priv->rx_filer_enable = 1;
+	/* always enable rx filer*/
+	priv->rx_filer_enable = 1;
 	/* Enable most messages by default */
 	priv->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1;
 
drivers/net/gianfar.h +53 -0

87 lines not on this page · raw message

drivers/net/gianfar_ethtool.c +955 -1

984 lines not on this page · raw message

#1 lore raw
Quoted 1 line · Sebastian Pöhn

This patch adds all missing functionalities for nfc except GRXFH.

Just some trivial comments.

drivers/net/gianfar_ethtool.c

Quoted 1 line
drivers/net/gianfar_ethtool.c +0 -0

[]

Quoted 5 lines
drivers/net/gianfar_ethtool.c +5 -0
+static void gfar_swap(void *a, void *b, int size)
+{
+	u32 t1 = *(u32 *) a;
+	u32 t2 = *(u32 *) (a + 4);
+	u32 t3 = *(u32 *) (a + 8);

drivers/net/gianfar_ethtool.c static int gfar_set_hash_opts(struct gfar_private *priv, struct ethtool_rxnfc *c · line 851

Quoted 10 lines
drivers/net/gianfar_ethtool.c +10 -0
+	u32 t4 = *(u32 *) (a + 12);
+	*(u32 *) a = *(u32 *) b;
+	*(u32 *) (a + 4) = *(u32 *) (b + 4);
+	*(u32 *) (a + 8) = *(u32 *) (b + 8);
+	*(u32 *) (a + 12) = *(u32 *) (b + 12);
+	*(u32 *) b = t1;
+	*(u32 *) (b + 4) = t2;
+	*(u32 *) (b + 8) = t3;
+	*(u32 *) (b + 12) = t4;
+}

Doesn't this read better by casting a and b
to temporary pointers and using swap?

static void gfar_swap(void *a, void *b, int size)

{
	u32 *_a = a;
	u32 *_b = b;

	swap(_a[0], _b[0]);
	swap(_a[1], _b[1]);
	swap(_a[2], _b[2]);
	swap(_a[3], _b[3]);
}

[]

drivers/net/gianfar_ethtool.c static int gfar_set_hash_opts(struct gfar_private *priv, struct ethtool_rxnfc *c · line 1411

Quoted 3 lines
drivers/net/gianfar_ethtool.c +3 -0
+	mask_table = kzalloc(
+			sizeof(struct gfar_mask_entry) * (MAX_FILER_CACHE_IDX
+					/ 2 + 1), GFP_KERNEL);

mask_table = kcalloc(MAX_FILER_CACHE_IDX / 2 + 1,
sizeof(struct gfar_mask_entry), GFP_KERNEL)

[]

drivers/net/gianfar_ethtool.c static int gfar_set_hash_opts(struct gfar_private *priv, struct ethtool_rxnfc *c · line 1530

Quoted 4 lines
drivers/net/gianfar_ethtool.c +4 -0
+			netdev_err(priv->ndev,
+				"Adding this rule is not possible,"
+				" because this flow-type is not supported"
+				" by hardware!\n");

Could you review your logging messages for grammar and spacing please.

For all these logging messages, you really should ignore what is now an arbitrary 80 column limit and not break the format string up on multiple lines.

It makes grep harder and when you write them, you don't quite read them back to yourself normally. You wouldn't generally use a comma between possible and because.

			netdev_err(priv->ndev,
				   "Adding this rule is not possible because this flow-type is not supported by hardware!\n");

or maybe:

			netdev_err(priv->ndev,
				   "Rule not added.  Flow-type not supported by hardware!\n");

Maybe it should be:

	"Flow-type (%(some type)) not supported by hardware!\n",
	flow->some_type

drivers/net/gianfar_ethtool.c static int gfar_set_hash_opts(struct gfar_private *priv, struct ethtool_rxnfc *c · line 1604

Quoted 3 lines
drivers/net/gianfar_ethtool.c +3 -0
+				netdev_err(priv->ndev,
+				"There is already an element on ID %d\n",
+				flow->location);

I think it nicer to not align any function params on indent level but where possible on open paren.

				netdev_err(priv->ndev,
					   "There is already an element on ID %d\n",
					   flow->location);

Aligning on indent level is confusing.
If you really need or want to to this, it's better to change the indent level inwards
for extra long lines.

			netdev_err(priv->ndev,

"Adding this rule is not possible because this flow-type is not supported by hardware!\n");

That way you can see if the line is too long for a message logging form and should be shortened somehow.