32 * ========== RX side routines ==========
33 */
34
35 #define RGE_DBG RGE_DBG_RECV /* debug flag for this code */
36
37 static uint32_t rge_atomic_reserve(uint32_t *count_p, uint32_t n);
38 #pragma inline(rge_atomic_reserve)
39
40 static uint32_t
41 rge_atomic_reserve(uint32_t *count_p, uint32_t n)
42 {
43 uint32_t oldval;
44 uint32_t newval;
45
46 /* ATOMICALLY */
47 do {
48 oldval = *count_p;
49 newval = oldval - n;
50 if (oldval <= n)
51 return (0); /* no resources left */
52 } while (cas32(count_p, oldval, newval) != oldval);
53
54 return (newval);
55 }
56
57 /*
58 * Atomically increment a counter
59 */
60 static void rge_atomic_renounce(uint32_t *count_p, uint32_t n);
61 #pragma inline(rge_atomic_renounce)
62
63 static void
64 rge_atomic_renounce(uint32_t *count_p, uint32_t n)
65 {
66 uint32_t oldval;
67 uint32_t newval;
68
69 /* ATOMICALLY */
70 do {
71 oldval = *count_p;
72 newval = oldval + n;
73 } while (cas32(count_p, oldval, newval) != oldval);
74 }
75
76 /*
77 * Callback code invoked from STREAMs when the recv data buffer is free
78 * for recycling.
79 */
80 void
81 rge_rx_recycle(caddr_t arg)
82 {
83 rge_t *rgep;
84 dma_buf_t *rx_buf;
85 sw_rbd_t *free_srbdp;
86 uint32_t slot_recy;
87
88 rx_buf = (dma_buf_t *)arg;
89 rgep = (rge_t *)rx_buf->private;
90
91 /*
92 * In rge_unattach() and rge_attach(), this callback function will
93 * also be called to free mp in rge_fini_rings() and rge_init_rings().
|
32 * ========== RX side routines ==========
33 */
34
35 #define RGE_DBG RGE_DBG_RECV /* debug flag for this code */
36
37 static uint32_t rge_atomic_reserve(uint32_t *count_p, uint32_t n);
38 #pragma inline(rge_atomic_reserve)
39
40 static uint32_t
41 rge_atomic_reserve(uint32_t *count_p, uint32_t n)
42 {
43 uint32_t oldval;
44 uint32_t newval;
45
46 /* ATOMICALLY */
47 do {
48 oldval = *count_p;
49 newval = oldval - n;
50 if (oldval <= n)
51 return (0); /* no resources left */
52 } while (atomic_cas_32(count_p, oldval, newval) != oldval);
53
54 return (newval);
55 }
56
57 /*
58 * Atomically increment a counter
59 */
60 static void rge_atomic_renounce(uint32_t *count_p, uint32_t n);
61 #pragma inline(rge_atomic_renounce)
62
63 static void
64 rge_atomic_renounce(uint32_t *count_p, uint32_t n)
65 {
66 uint32_t oldval;
67 uint32_t newval;
68
69 /* ATOMICALLY */
70 do {
71 oldval = *count_p;
72 newval = oldval + n;
73 } while (atomic_cas_32(count_p, oldval, newval) != oldval);
74 }
75
76 /*
77 * Callback code invoked from STREAMs when the recv data buffer is free
78 * for recycling.
79 */
80 void
81 rge_rx_recycle(caddr_t arg)
82 {
83 rge_t *rgep;
84 dma_buf_t *rx_buf;
85 sw_rbd_t *free_srbdp;
86 uint32_t slot_recy;
87
88 rx_buf = (dma_buf_t *)arg;
89 rgep = (rge_t *)rx_buf->private;
90
91 /*
92 * In rge_unattach() and rge_attach(), this callback function will
93 * also be called to free mp in rge_fini_rings() and rge_init_rings().
|