Re: [PATCH] gianfar v5: implement nfc
From: Joe Perches <joe@perches.com>
Date: 2011-06-21 17:44:14
On Mon, 2011-06-20 at 11:39 +0200, Sebastian Pöhn wrote:
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. Signed-off-by: Sebastian Poehn <redacted>
Just a bit more trivia... []
+/* Swaps the 0xFF80 masked bits of a1<>a2 and b1<>b2 */
+static void gfar_swap_ff80_bits(struct gfar_filer_entry *a1,
+ struct gfar_filer_entry *a2, struct gfar_filer_entry *b1,
+ struct gfar_filer_entry *b2)
+{
+ u32 temp[4];
+ temp[0] = a1->ctrl & 0xFF80;
+ temp[1] = a2->ctrl & 0xFF80;
+ temp[2] = b1->ctrl & 0xFF80;
+ temp[3] = b2->ctrl & 0xFF80;
+
+ a1->ctrl &= ~0xFF80;
+ a2->ctrl &= ~0xFF80;
+ b1->ctrl &= ~0xFF80;
+ b2->ctrl &= ~0xFF80;
+
+ a1->ctrl |= temp[1];
+ a2->ctrl |= temp[0];
+ b1->ctrl |= temp[3];
+ b2->ctrl |= temp[2];
+}
maybe add a macro similar to swap:
#define swap_bits(a, b, bits) \
do { \
typeof(a) _bits = bits; \
typeof(a) _a_bits = (a) & _bits; \
typeof(a) _b_bits = (b) & _bits; \
\
(a) &= ~_bits; \
(b) &= ~_bits; \
\
(a) |= _b_bits; \
(b) |= _a_bits; \
} while (0)
and use this macro directly in gfar_sort_mask_table?
swap_bits(temp_table->fe[new_first],
temp_table->fe[old_first], 0xff80);
swap_bits(temp_table->fe[new_last],
temp_table->fe[old_last], 0xff80);
And maybe 0xff80 should be a #define?