* [PATCH 2/4] b44: wol setup for older 4401
@ 2006-05-24 14:40 Gary Zambrano
2006-05-24 22:13 ` Francois Romieu
0 siblings, 1 reply; 3+ messages in thread
From: Gary Zambrano @ 2006-05-24 14:40 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
This patch adds wol support for the older 4401 revs.
Signed-off-by: Gary Zambrano <zambrano@broadcom.com>
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index b9e2462..6f4d1d4 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -1448,6 +1448,93 @@ static void b44_poll_controller(struct n
}
#endif
+static inline void bwfilter_table(struct b44 *bp,
+ u32 *pattern,
+ u32 bytes,
+ u32 table_offset)
+{
+ u32 i;
+
+ for (i = 0; i < bytes; i += sizeof(u32)) {
+ bw32(bp, B44_FILT_ADDR, table_offset + i);
+ bw32(bp, B44_FILT_DATA, pattern[i / sizeof(u32)]);
+ }
+}
+
+/* Setup two common magic packet patterns in the b44 WOL
+ * pattern matching filter.
+ */
+static void b44_setup_pseudo_magicp(struct b44 *bp)
+{
+
+ u32 val;
+ int plen0, plen1, max, i, j;
+ u8 *pwol_pattern;
+ u8 *pwol_mask;
+
+ pwol_pattern = kmalloc(B44_WOL_PATTERN_SIZE, GFP_KERNEL);
+ pwol_mask = kmalloc(B44_WOL_MASK_SIZE, GFP_KERNEL);
+
+ /* UDP magic packet pattern */
+ memset(pwol_pattern, 0, B44_WOL_PATTERN_SIZE);
+ memset(pwol_pattern + 42, 0xff, 6); /* sync pattern */
+ max = ETH_ALEN;
+ for (i = 0; i < 14; ++i) {
+ if (i == 13)
+ max = 2;
+ for (j = 0; j < max; ++j) {
+ pwol_pattern[42 + 6 +
+ (i * ETH_ALEN) + j] =
+ bp->dev->dev_addr[j];
+ }
+ }
+
+ memset(pwol_mask, 0, B44_WOL_MASK_SIZE);
+ pwol_mask[5] = 0xfc;
+ memset(pwol_mask + 6, 0xff, 10);
+ plen0 = B44_WOL_PATTERN_SIZE - 1;
+
+ bwfilter_table(bp, (u32 *)pwol_pattern,
+ B44_WOL_PATTERN_SIZE, B44_WOL_PATTERN_BASE);
+
+ bwfilter_table(bp, (u32 *)pwol_mask,
+ B44_WOL_MASK_SIZE, B44_WOL_MASK_BASE);
+
+ /* raw ethernet II magic packet pattern */
+ memset(pwol_pattern, 0, B44_WOL_PATTERN_SIZE);
+ memset(pwol_pattern + 14, 0xff, 6); /* sync pattern */
+ max = ETH_ALEN;
+ for (i = 0; i < 16; ++i) {
+ for (j = 0; j < max; ++j) {
+ pwol_pattern[14 + 6 +
+ (i * ETH_ALEN) + j] =
+ bp->dev->dev_addr[j];
+ }
+ }
+
+ memset(pwol_mask, 0, B44_WOL_MASK_SIZE);
+ pwol_mask[2] = 0xf0;
+ memset(pwol_mask + 3, 0xff, 11);
+ pwol_mask[14] = 0xf;
+ plen1 = 14 + 6 + 96 - 1;
+
+ bwfilter_table(bp, (u32 *)pwol_pattern, B44_WOL_PATTERN_SIZE,
+ B44_WOL_PATTERN_BASE + B44_WOL_PATTERN_SIZE);
+ bwfilter_table(bp, (u32 *)pwol_mask, B44_WOL_MASK_SIZE,
+ B44_WOL_MASK_BASE + B44_WOL_MASK_SIZE);
+
+ /* set this pattern's length: one less than the real length */
+ val = plen0 | (plen1 << 8) | WKUP_LEN_ENABLE_TWO;
+ bw32(bp, B44_WKUP_LEN, val);
+
+ /* enable chip wakeup pattern matching */
+ val = br32(bp, B44_DEVCTRL);
+ bw32(bp, B44_DEVCTRL, val | DEVCTRL_PFE);
+
+ kfree(pwol_mask);
+ kfree(pwol_pattern);
+
+}
static void b44_setup_wol(struct b44 *bp)
{
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 2/4] b44: wol setup for older 4401
2006-05-24 14:40 [PATCH 2/4] b44: wol setup for older 4401 Gary Zambrano
@ 2006-05-24 22:13 ` Francois Romieu
2006-05-24 15:33 ` Gary Zambrano
0 siblings, 1 reply; 3+ messages in thread
From: Francois Romieu @ 2006-05-24 22:13 UTC (permalink / raw)
To: Gary Zambrano; +Cc: Jeff Garzik, netdev
Gary Zambrano <zambrano@broadcom.com> :
[...]
> diff --git a/drivers/net/b44.c b/drivers/net/b44.c
> index b9e2462..6f4d1d4 100644
> --- a/drivers/net/b44.c
> +++ b/drivers/net/b44.c
[...]
> +static void b44_setup_pseudo_magicp(struct b44 *bp)
> +{
> +
> + u32 val;
> + int plen0, plen1, max, i, j;
> + u8 *pwol_pattern;
> + u8 *pwol_mask;
> +
> + pwol_pattern = kmalloc(B44_WOL_PATTERN_SIZE, GFP_KERNEL);
> + pwol_mask = kmalloc(B44_WOL_MASK_SIZE, GFP_KERNEL);
> +
> + /* UDP magic packet pattern */
> + memset(pwol_pattern, 0, B44_WOL_PATTERN_SIZE);
> + memset(pwol_pattern + 42, 0xff, 6); /* sync pattern */
kmalloc can fail. It should be checked.
> + max = ETH_ALEN;
> + for (i = 0; i < 14; ++i) {
> + if (i == 13)
> + max = 2;
> + for (j = 0; j < max; ++j) {
> + pwol_pattern[42 + 6 +
> + (i * ETH_ALEN) + j] =
> + bp->dev->dev_addr[j];
Indentation went strange here.
--
Ueimor
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 2/4] b44: wol setup for older 4401
2006-05-24 22:13 ` Francois Romieu
@ 2006-05-24 15:33 ` Gary Zambrano
0 siblings, 0 replies; 3+ messages in thread
From: Gary Zambrano @ 2006-05-24 15:33 UTC (permalink / raw)
To: Francois Romieu; +Cc: Jeff Garzik, netdev
On Thu, 2006-05-25 at 00:13 +0200, Francois Romieu wrote:
> > + pwol_pattern = kmalloc(B44_WOL_PATTERN_SIZE, GFP_KERNEL);
> > + pwol_mask = kmalloc(B44_WOL_MASK_SIZE, GFP_KERNEL);
> > +
> kmalloc can fail. It should be checked.
Yep. Thanks.
> > + max = ETH_ALEN;
> > + for (i = 0; i < 14; ++i) {
> > + if (i == 13)
> > + max = 2;
> > + for (j = 0; j < max; ++j) {
> > + pwol_pattern[42 + 6 +
> > + (i * ETH_ALEN) + j] =
> > + bp->dev->dev_addr[j];
>
> Indentation went strange here.
>
Will adjust.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-05-24 22:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-24 14:40 [PATCH 2/4] b44: wol setup for older 4401 Gary Zambrano
2006-05-24 22:13 ` Francois Romieu
2006-05-24 15:33 ` Gary Zambrano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox