TL-WN821N

Introduction
The TL-WN821N is a USB dongle with Atheros chipset, that complies with IEEE 802.11n (Draft 2.0), IEEE 802.11g, and IEEE 802.11b standards. Described setup is done with 2.6.30 gentoo kernel. The configuration is a bit tricky and it not working at full speed.

Kernel Options
During build of drivers, in case you have incorrect kernel setup, it will print an error, showing what you have to change. But generally it is:

Patch
For driver to build you need to patch a kernel with following patch: diff -urp linux-2.6.30-gentoo-r4/include/net/genetlink.h linux-2.6.30-gentoo-r4/include/net/genetlink.h {{Code|diff -urp linux-2.6.30-gentoo-r4/net/netlink/genetlink.c linux-2.6.30-gentoo-r4/net/netlink/genetlink.c| --- linux-2.6.30-gentoo-r4/net/netlink/genetlink.c     2009-06-10 07:05:27.000000000 +0400 +++ linux-2.6.30-gentoo-r4/net/netlink/genetlink.c 2009-08-18 02:41:51.498005864 +0400 @@ -446,8 +446,15 @@ static int genl_rcv_msg(struct sk_buff *                       return -EOPNOTSUPP;

genl_unlock; -              err = netlink_dump_start(genl_sock, skb, nlh, -                                        ops->dumpit, ops->done); +              err = 0; +              if (family->pre_dumpit) +              err = family->pre_dumpit; +              if (!err) +                      err = netlink_dump_start(genl_sock, skb, nlh, +                               ops->dumpit, ops->done); +              if (family->post_dumpit) +                      family->post_dumpit; +               genl_lock; return err; } @@ -469,7 +476,15 @@ static int genl_rcv_msg(struct sk_buff *       info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN;        info.attrs = family->attrbuf;

-      return ops->doit(skb, &info); +      err = 0; +      if (family->pre_doit) +              err = family->pre_doit(skb, &info); +      if (!err) +              err = ops->doit(skb, &info); +      if (family->post_doit) +              family->post_doit; +      return err; + }

static void genl_rcv(struct sk_buff *skb) }}

Download
First of all you should download and untar the drivers:

Verify check sum:

Untar it:

Go to directory:

The MD5 for the archive is 8dc6af49103f04fb7589408045ce311a

Patch
You have to apply some patches to the driver as well, for it to build well. {{Code|diff -urp compat-wireless-2009-02-22_AR9170_230209/drivers/net/b44.c compat-wireless-2009-02-22_AR9170_230209/drivers/net/b44.c| --- compat-wireless-2009-02-22_AR9170_230209/drivers/net/b44.c    2009-02-22 08:14:13.000000000 +0300 +++ compat-wireless-2009-02-22_AR9170_230209/drivers/net/b44.c 2009-08-18 02:49:05.859159438 +0400 @@ -880,7 +880,7 @@ static int b44_poll(struct napi_struct *               netif_rx_complete(netdev, napi); -               netif_rx_complete(napi); +               napi_complete(napi);                b44_enable_ints(bp);        } @@ -916,7 +916,7 @@ static irqreturn_t b44_interrupt(int irq if (netif_rx_schedule_prep(dev, &bp->napi)) { -              if (netif_rx_schedule_prep(&bp->napi)) { +              if (napi_schedule_prep(&bp->napi)) { /* NOTE: These writes are posted by the readback of                        *       the ISTAT register below. @@ -926,7 +926,7 @@ static irqreturn_t b44_interrupt(int irq                       __netif_rx_schedule(dev, &bp->napi); -                       __netif_rx_schedule(&bp->napi); +                       __napi_schedule(&bp->napi);                } else {                        printk(KERN_ERR PFX "%s: Error, poll already scheduled\n", }} diff -urp compat-wireless-2009-02-22_AR9170_230209/drivers/net/wireless/at76c50x-usb.c compat-wireless-2009-02-22_AR9170_230209/drivers/net/wireless/at76c50x-usb.c
 * 1) if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
 * 1) else
 * 1) endif
 * 1) if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
 * 1) else
 * 1) endif
 * 1) if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
 * 1) else
 * 1) endif

Build and install
Finally after all you may build and install the driver

Also you should copy firmware files to /lib/firmware

After this you should reboot

Usage
Just add module to kernel and configure it with your favorite wireless tool.

Module was tested with wpa_supplicant, to connect to WPA-PSK network. It works at N speed (300MBit) with 2.6.35 gentoo kernel (tested with Ubuntu mainline kernel on July 24, 2010)

Links

 * TL-WN821N official product page
 * Gentoo Forum thread about TL-WN821N