77 * Note, this example merely shows the structure of this function.
78 * Different devices will manage their state in different ways. Like other
79 * examples, this assumes that the device has state in a structure called
80 * example_t and that there is a lock which keeps track of that state.
81 */
82 static char *example_priv_props[] = {
83 "_rx_intr_throttle",
84 "_tx_intr_throttle",
85 NULL
86 };
87
88 static int
89 example_m_getprop_private(example_t *ep, const char *pr_name, uint_t pr_valsize,
90 void *pr_val)
91 {
92 uint32_t val;
93
94 ASSERT(MUTEX_HELD(&ep->ep_lock));
95 if (strcmp(pr_name, example_priv_props[0] == 0) {
96 val = ep->ep_rx_itr;
97 } else if (strcmp(pr_name, exampe_priv_props[1] == 0) {
98 val = ep->ep_tx_itr;
99 } else {
100 return (ENOTSUP);
101 }
102
103 /*
104 * Due to issues in the GLDv3, these must be returned as string
105 * properties.
106 */
107 if (snprintf(pr_val, pr_valsize, "%d", val) >= pr_valsize)
108 return (EOVERFLOW);
109
110 return (0);
111 }
112
113 static int
114 example_m_getprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
115 uint_t pr_valsize, void *pr_val)
116 {
117 int ret = 0;
162
163 mutex_exit(&ep->ep_lock);
164
165 return (ret);
166 }
167
168 ERRORS
169 The device driver may return one of the following errors. While this
170 list is not intended to be exhaustive, it is recommended to use one of
171 these if possible.
172
173 ENOTSUP This error should be used whenever an unknown or
174 unsupported property is encountered.
175
176 EOVERFLOW This error should be used when pr_valsize is smaller
177 than the required size for a given value.
178
179 SEE ALSO
180 mac(9E), mac_register(9F), strcmp(9F), mac_register(9S)
181
182 illumos November 15, 2016 illumos
|
77 * Note, this example merely shows the structure of this function.
78 * Different devices will manage their state in different ways. Like other
79 * examples, this assumes that the device has state in a structure called
80 * example_t and that there is a lock which keeps track of that state.
81 */
82 static char *example_priv_props[] = {
83 "_rx_intr_throttle",
84 "_tx_intr_throttle",
85 NULL
86 };
87
88 static int
89 example_m_getprop_private(example_t *ep, const char *pr_name, uint_t pr_valsize,
90 void *pr_val)
91 {
92 uint32_t val;
93
94 ASSERT(MUTEX_HELD(&ep->ep_lock));
95 if (strcmp(pr_name, example_priv_props[0] == 0) {
96 val = ep->ep_rx_itr;
97 } else if (strcmp(pr_name, example_priv_props[1] == 0) {
98 val = ep->ep_tx_itr;
99 } else {
100 return (ENOTSUP);
101 }
102
103 /*
104 * Due to issues in the GLDv3, these must be returned as string
105 * properties.
106 */
107 if (snprintf(pr_val, pr_valsize, "%d", val) >= pr_valsize)
108 return (EOVERFLOW);
109
110 return (0);
111 }
112
113 static int
114 example_m_getprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
115 uint_t pr_valsize, void *pr_val)
116 {
117 int ret = 0;
162
163 mutex_exit(&ep->ep_lock);
164
165 return (ret);
166 }
167
168 ERRORS
169 The device driver may return one of the following errors. While this
170 list is not intended to be exhaustive, it is recommended to use one of
171 these if possible.
172
173 ENOTSUP This error should be used whenever an unknown or
174 unsupported property is encountered.
175
176 EOVERFLOW This error should be used when pr_valsize is smaller
177 than the required size for a given value.
178
179 SEE ALSO
180 mac(9E), mac_register(9F), strcmp(9F), mac_register(9S)
181
182 illumos February 15, 2020 illumos
|