igb: Make sure EITR interval is within range
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 30 Jun 2012 03:24:10 +0000 (11:24 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 30 Jun 2012 03:24:10 +0000 (11:24 +0800)
Suggested-by: dillon@
sys/dev/netif/igb/if_igb.c
sys/dev/netif/igb/if_igb.h

index 3b3c361..d18c44e 100644 (file)
@@ -3362,9 +3362,16 @@ igb_set_eitr(struct igb_softc *sc, int idx, int rate)
                         */
                } else {
                        eitr = 1000000 / rate;
-                       eitr <<= 2;
+                       eitr <<= IGB_EITR_INTVL_SHIFT;
+               }
+
+               if (eitr == 0) {
+                       /* Don't disable it */
+                       eitr = 1 << IGB_EITR_INTVL_SHIFT;
+               } else if (eitr > IGB_EITR_INTVL_MASK) {
+                       /* Don't allow it to be too large */
+                       eitr = IGB_EITR_INTVL_MASK;
                }
-               eitr &= 0x7FFC;
        }
        if (sc->hw.mac.type == e1000_82575)
                eitr |= eitr << 16;
index 009e5aa..374d467 100644 (file)
 #define IGB_RETA_SHIFT                 0
 #define IGB_RETA_SHIFT_82575           6
 
+#define IGB_EITR_INTVL_MASK            0x7ffc
+#define IGB_EITR_INTVL_SHIFT           2
+
 struct igb_softc;
 
 /*