Sync with FreeBSD(if_an.c 1.2.2.15, if_aironet_ieee.h 1.1.2.9)
authorJoerg Sonnenberger <joerg@dragonflybsd.org>
Thu, 28 Jul 2005 16:55:17 +0000 (16:55 +0000)
committerJoerg Sonnenberger <joerg@dragonflybsd.org>
Thu, 28 Jul 2005 16:55:17 +0000 (16:55 +0000)
- Bump up the general and status RID sizes
- Clear out an_dma_vaddr on free so we can test to see if dma is
  setup when the card is kldunloaded/kldloaded etc. only for MPI350
- Notify on RID read overflow and truncate this currently causes
  a panic in -stable when the stack during an ifconfig an0 is done
  with newer firmware

Obtained-from: FreeBSD
Submitted-by: Sepherosa Ziehau <sepherosa@gmail.com>
sys/dev/netif/an/if_aironet_ieee.h
sys/dev/netif/an/if_an.c

index ce6e1ab..b1e82f9 100644 (file)
@@ -30,7 +30,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/an/if_aironet_ieee.h,v 1.1.2.7 2003/02/01 03:25:12 ambrisko Exp $
- * $DragonFly: src/sys/dev/netif/an/if_aironet_ieee.h,v 1.3 2005/07/28 16:52:44 joerg Exp $
+ * $DragonFly: src/sys/dev/netif/an/if_aironet_ieee.h,v 1.4 2005/07/28 16:55:17 joerg Exp $
  */
 
 #ifndef _IF_AIRONET_IEEE_H
@@ -337,7 +337,7 @@ struct an_ltv_genconfig {
        u_int8_t                an_magic_packet_action; /* 0x98 */
        u_int8_t                an_magic_packet_ctl;    /* 0x99 */
        u_int16_t               an_rsvd9;
-       u_int16_t               an_spare[13];
+       u_int16_t               an_spare[19];
 };
 
 #define AN_OPMODE_IBSS_ADHOC                   0x0000
@@ -593,7 +593,7 @@ struct an_ltv_status {
        u_int8_t                an_avg_noise_prev_min_db;       /* 0x7D */
        u_int8_t                an_max_noise_prev_min_pc;       /* 0x7E */
        u_int8_t                an_max_noise_prev_min_db;       /* 0x7F */
-       u_int16_t               an_spare[8];
+       u_int16_t               an_spare[18];
 };
 
 #define AN_STATUS_OPMODE_CONFIGURED            0x0001
index f53749f..d0357ff 100644 (file)
@@ -30,7 +30,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/an/if_an.c,v 1.2.2.13 2003/02/11 03:32:48 ambrisko Exp $
- * $DragonFly: src/sys/dev/netif/an/if_an.c,v 1.29 2005/07/28 16:52:44 joerg Exp $
+ * $DragonFly: src/sys/dev/netif/an/if_an.c,v 1.30 2005/07/28 16:55:17 joerg Exp $
  */
 
 /*
@@ -506,6 +506,7 @@ an_dma_free(sc, dma)
 {
        bus_dmamap_unload(sc->an_dtag, dma->an_dma_map);
        bus_dmamem_free(sc->an_dtag, dma->an_dma_vaddr, dma->an_dma_map);
+       dma->an_dma_vaddr = NULL;
        bus_dmamap_destroy(sc->an_dtag, dma->an_dma_map);
 }
 
@@ -1381,6 +1382,8 @@ an_read_record(sc, ltv)
                        *ptr2 = CSR_READ_1(sc, AN_DATA1);
                }
        } else { /* MPI-350 */
+               if (sc->an_rid_buffer.an_dma_vaddr == NULL)
+                       return(EIO);
                an_rid_desc.an_valid = 1;
                an_rid_desc.an_len = AN_RID_BUFFER_SIZE;
                an_rid_desc.an_rid = 0;
@@ -1414,11 +1417,17 @@ an_read_record(sc, ltv)
                        an_rid_desc.an_len = an_ltv->an_len;
                }
 
-               if (an_rid_desc.an_len > 2)
-                       bcopy(&an_ltv->an_type,
-                             &ltv->an_val, 
-                             an_rid_desc.an_len - 2);
-               ltv->an_len = an_rid_desc.an_len + 2;
+               len = an_rid_desc.an_len;
+               if (len > (ltv->an_len - 2)) {
+                       if_printf(&sc->arpcom.ac_if,
+                                 "record length mismatch -- expected %d, "
+                                 "got %d for Rid %x\n",
+                                 ltv->an_len - 2, len, ltv->an_type);
+                       len = ltv->an_len - 2;
+               } else {
+                       ltv->an_len = len + 2;
+               }
+               bcopy(&an_ltv->an_type, &ltv->an_val, len);
        }
 
        if (an_dump)