Print this page
MFV: illumos-gate@7ec6bfcf4280022b95218f03e28fb50217e4b6ff
9902 mac: mac_soft_ring_poll should use size_t
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Ryan Zezeski <ryan.zeseski@joyent.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Toomas Soome <tsoome@me.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/mac_soft_ring.h
          +++ new/usr/src/uts/common/sys/mac_soft_ring.h
↓ open down ↓ 175 lines elided ↑ open up ↑
 176  176          /*
 177  177           * Upcall Function for fanout, Rx processing etc. Perhaps
 178  178           * the same 3 members below can be used for Tx
 179  179           * processing, but looking around, mac_rx_func_t has
 180  180           * proliferated too much into various files at different
 181  181           * places. I am leaving the consolidation battle for
 182  182           * another day.
 183  183           */
 184  184          mac_direct_rx_t         sr_func;        /* srs_lock */
 185  185          void                    *sr_arg1;       /* srs_lock */
 186      -        mac_resource_handle_t   sr_arg2;        /* srs_lock */
      186 +        mac_resource_handle_t   sr_arg2;        /* srs_lock */
 187  187          mac_rx_func_t           sr_lower_proc;  /* Atomically changed */
 188  188          uint32_t                sr_poll_pkt_cnt;
 189  189          uint32_t                sr_poll_thres;
 190  190  
 191  191          /* mblk cnt to apply flow control */
 192  192          uint32_t                sr_hiwat;
 193  193          /* mblk cnt to relieve flow control */
 194  194          uint32_t                sr_lowat;
 195  195          mac_rx_stats_t          sr_stat;
 196  196  
↓ open down ↓ 182 lines elided ↑ open up ↑
 379  379          mac_cpus_t      srs_cpu;
 380  380  
 381  381          mac_srs_rx_t    srs_rx;
 382  382          mac_srs_tx_t    srs_tx;
 383  383          kstat_t         *srs_ksp;
 384  384  };
 385  385  
 386  386  /*
 387  387   * type flags - combination allowed to process and drain the queue
 388  388   */
 389      -#define ST_RING_WORKER_ONLY     0x0001  /* Worker thread only */
      389 +#define ST_RING_WORKER_ONLY     0x0001  /* Worker thread only */
 390  390  #define ST_RING_ANY             0x0002  /* Any thread can process the queue */
 391  391  #define ST_RING_TCP             0x0004
 392  392  #define ST_RING_UDP             0x0008
 393  393  #define ST_RING_OTH             0x0010
 394  394  
 395  395  #define ST_RING_BW_CTL          0x0020
 396  396  #define ST_RING_TX              0x0040
 397  397  
 398  398  /*
 399  399   * State flags.
↓ open down ↓ 133 lines elided ↑ open up ↑
 533  533          if (((mac_srs)->srs_state & (SRS_POLLING_CAPAB|SRS_POLLING)) == \
 534  534              (SRS_POLLING_CAPAB|SRS_POLLING)) {                          \
 535  535                  (mac_srs)->srs_state &= ~SRS_POLLING;                   \
 536  536                  (void) mac_hwring_enable_intr((mac_ring_handle_t)       \
 537  537                      (mac_srs)->srs_ring);                               \
 538  538                  (mac_srs)->srs_rx.sr_poll_off++;                        \
 539  539          }                                                               \
 540  540  }
 541  541  
 542  542  #define MAC_COUNT_CHAIN(mac_srs, head, tail, cnt, sz)   {       \
 543      -        mblk_t          *tmp;                                   \
      543 +        mblk_t          *tmp;                                   \
 544  544          boolean_t       bw_ctl = B_FALSE;                       \
 545  545                                                                  \
 546  546          ASSERT((head) != NULL);                                 \
 547  547          cnt = 0;                                                \
 548  548          sz = 0;                                                 \
 549  549          if ((mac_srs)->srs_type & SRST_BW_CONTROL)              \
 550  550                  bw_ctl = B_TRUE;                                \
 551  551          tmp = tail = (head);                                    \
 552  552          if ((head)->b_next == NULL) {                           \
 553  553                  cnt = 1;                                        \
↓ open down ↓ 18 lines elided ↑ open up ↑
 572  572   * of poll mode). If no one is processing the queue, then
 573  573   * acquire the PROC and signal the poll thread to check the
 574  574   * interface for packets and get the interface back to interrupt
 575  575   * mode if nothing is found.
 576  576   */
 577  577  #define MAC_UPDATE_SRS_COUNT_LOCKED(mac_srs, cnt) {                     \
 578  578          mac_srs_rx_t    *srs_rx = &(mac_srs)->srs_rx;                   \
 579  579          ASSERT(MUTEX_HELD(&(mac_srs)->srs_lock));                       \
 580  580                                                                          \
 581  581          srs_rx->sr_poll_pkt_cnt -= cnt;                                 \
 582      -        if ((srs_rx->sr_poll_pkt_cnt <= srs_rx->sr_poll_thres) &&       \
 583      -                (((mac_srs)->srs_state &                                \
 584      -                (SRS_POLLING|SRS_PROC|SRS_GET_PKTS)) == SRS_POLLING))   \
      582 +        if ((srs_rx->sr_poll_pkt_cnt <= srs_rx->sr_poll_thres) &&       \
      583 +            (((mac_srs)->srs_state &                                    \
      584 +            (SRS_POLLING|SRS_PROC|SRS_GET_PKTS)) == SRS_POLLING))       \
 585  585          {                                                               \
 586  586                  (mac_srs)->srs_state |= (SRS_PROC|SRS_GET_PKTS);        \
 587      -                cv_signal(&(mac_srs)->srs_cv);                          \
      587 +                cv_signal(&(mac_srs)->srs_cv);                          \
 588  588                  srs_rx->sr_below_hiwat++;                               \
 589  589          }                                                               \
 590  590  }
 591  591  
 592  592  /*
 593  593   * The following two macros are used to update the inbound packet and byte.
 594  594   * count. The packet and byte count reflect the packets and bytes that are
 595  595   * taken out of the SRS's queue, i.e. indicating they are being delivered.
 596  596   * The srs_count and srs_size are updated in different locations as the
 597  597   * srs_size is also used to take into account any bandwidth limits. The
↓ open down ↓ 34 lines elided ↑ open up ↑
 632  632  
 633  633  /* Soft rings */
 634  634  extern void mac_soft_ring_init(void);
 635  635  extern void mac_soft_ring_finish(void);
 636  636  extern void mac_fanout_setup(mac_client_impl_t *, flow_entry_t *,
 637  637      mac_resource_props_t *, mac_direct_rx_t, void *, mac_resource_handle_t,
 638  638      cpupart_t *);
 639  639  
 640  640  extern void mac_soft_ring_worker_wakeup(mac_soft_ring_t *);
 641  641  extern void mac_soft_ring_blank(void *, time_t, uint_t, int);
 642      -extern mblk_t *mac_soft_ring_poll(mac_soft_ring_t *, int);
      642 +extern mblk_t *mac_soft_ring_poll(mac_soft_ring_t *, size_t);
 643  643  extern void mac_soft_ring_destroy(mac_soft_ring_t *);
 644  644  extern void mac_soft_ring_dls_bypass(void *, mac_direct_rx_t, void *);
 645  645  
 646  646  /* Rx SRS */
 647  647  extern mac_soft_ring_set_t *mac_srs_create(struct mac_client_impl_s *,
 648  648      flow_entry_t *, uint32_t, mac_direct_rx_t, void *, mac_resource_handle_t,
 649  649      mac_ring_t *);
 650  650  extern void mac_srs_free(mac_soft_ring_set_t *);
 651  651  extern void mac_srs_signal(mac_soft_ring_set_t *, uint_t);
 652  652  extern cpu_t *mac_srs_bind(mac_soft_ring_set_t *, processorid_t);
↓ open down ↓ 75 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX