@@ -724,8 +724,10 @@ generic_netmap_txsync(struct netmap_kring *kring, int flags)
724724 RD (2 , "Failed to replenish mbuf" );
725725 /* Here we could schedule a timer which
726726 * retries to replenish after a while,
727- * and notifies the when it manages
728- * to replenish some slots. */
727+ * and notifies the client when it
728+ * manages to replenish some slots. In
729+ * any case we break early to avoid
730+ * crashes. */
729731 break ;
730732 }
731733 IFRATE (rate_ctx .new .txrepl ++ );
@@ -735,13 +737,12 @@ generic_netmap_txsync(struct netmap_kring *kring, int flags)
735737 a .addr = addr ;
736738 a .len = len ;
737739 a .qevent = (nm_i == event );
738- /* XXX When not in txqdisc mode, we should ask
739- * notifications when NS_REPORT is set,
740- * or roughly every half ring. We can optimize this
741- * by lazily requesting notifications only when a
742- * transmission fails. Probably the best way is to
743- * break on failures and set notifications when
744- * ring->cur == ring->tail || nm_i != cur
740+ /* When not in txqdisc mode, we should ask
741+ * notifications when NS_REPORT is set, or roughly
742+ * every half ring. To optimize this, we set a
743+ * notification event when the client runs out of
744+ * TX ring space, or when transmission fails. In
745+ * the latter case we also break early.
745746 */
746747 tx_ret = nm_os_generic_xmit_frame (& a );
747748 if (unlikely (tx_ret )) {
@@ -830,20 +831,20 @@ generic_rx_handler(struct ifnet *ifp, struct mbuf *m)
830831 struct netmap_generic_adapter * gna = (struct netmap_generic_adapter * )na ;
831832 struct netmap_kring * kring ;
832833 u_int work_done ;
833- u_int rr = MBUF_RXQ (m ); // receive ring number
834+ u_int r = MBUF_RXQ (m ); /* receive ring number */
834835
835- if (rr >= na -> num_rx_rings ) {
836- rr = rr % na -> num_rx_rings ; // XXX expensive...
836+ if (r >= na -> num_rx_rings ) {
837+ r = r % na -> num_rx_rings ;
837838 }
838839
839- kring = & na -> rx_rings [rr ];
840+ kring = & na -> rx_rings [r ];
840841
841842 /* limit the size of the queue */
842843 if (unlikely (!gna -> rxsg && MBUF_LEN (m ) > kring -> ring -> nr_buf_size )) {
843844 /* This may happen when GRO/LRO features are enabled for
844845 * the NIC driver when the generic adapter does not
845846 * support RX scatter-gather. */
846- RD (5 , "Warning: driver pushed up big packet "
847+ RD (2 , "Warning: driver pushed up big packet "
847848 "(size=%d)" , (int )MBUF_LEN (m ));
848849 m_freem (m );
849850 } else if (unlikely (mbq_len (& kring -> rx_queue ) > 1024 )) {
@@ -854,17 +855,17 @@ generic_rx_handler(struct ifnet *ifp, struct mbuf *m)
854855
855856 if (netmap_generic_mit < 32768 ) {
856857 /* no rx mitigation, pass notification up */
857- netmap_generic_irq (na , rr , & work_done );
858+ netmap_generic_irq (na , r , & work_done );
858859 } else {
859860 /* same as send combining, filter notification if there is a
860861 * pending timer, otherwise pass it up and start a timer.
861862 */
862- if (likely (nm_os_mitigation_active (& gna -> mit [rr ]))) {
863+ if (likely (nm_os_mitigation_active (& gna -> mit [r ]))) {
863864 /* Record that there is some pending work. */
864- gna -> mit [rr ].mit_pending = 1 ;
865+ gna -> mit [r ].mit_pending = 1 ;
865866 } else {
866- netmap_generic_irq (na , rr , & work_done );
867- nm_os_mitigation_start (& gna -> mit [rr ]);
867+ netmap_generic_irq (na , r , & work_done );
868+ nm_os_mitigation_start (& gna -> mit [r ]);
868869 }
869870 }
870871}
0 commit comments