2972 minsize = sizeof (wl_ess_list_t);
2973 break;
2974 case MAC_PROP_WL_KEY_TAB:
2975 minsize = sizeof (wl_wep_key_tab_t);
2976 break;
2977 case MAC_PROP_WL_CREATE_IBSS:
2978 minsize = sizeof (wl_create_ibss_t);
2979 break;
2980 case MAC_PROP_WL_SETOPTIE:
2981 minsize = sizeof (wl_wpa_ie_t);
2982 break;
2983 case MAC_PROP_WL_DELKEY:
2984 minsize = sizeof (wl_del_key_t);
2985 break;
2986 case MAC_PROP_WL_KEY:
2987 minsize = sizeof (wl_key_t);
2988 break;
2989 case MAC_PROP_WL_MLME:
2990 minsize = sizeof (wl_mlme_t);
2991 break;
2992 }
2993
2994 return (valsize >= minsize);
2995 }
2996
2997 /*
2998 * mac_set_prop() sets MAC or hardware driver properties:
2999 *
3000 * - MAC-managed properties such as resource properties include maxbw,
3001 * priority, and cpu binding list, as well as the default port VID
3002 * used by bridging. These properties are consumed by the MAC layer
3003 * itself and not passed down to the driver. For resource control
3004 * properties, this function invokes mac_set_resources() which will
3005 * cache the property value in mac_impl_t and may call
3006 * mac_client_set_resource() to update property value of the primary
3007 * mac client, if it exists.
3008 *
3009 * - Properties which act on the hardware and must be passed to the
3010 * driver, such as MTU, through the driver's mc_setprop() entry point.
3011 */
3048 }
3049
3050 case MAC_PROP_LLIMIT:
3051 case MAC_PROP_LDECAY: {
3052 uint32_t learnval;
3053
3054 if (valsize < sizeof (learnval) ||
3055 (mip->mi_state_flags & MIS_IS_VNIC))
3056 return (EINVAL);
3057 bcopy(val, &learnval, sizeof (learnval));
3058 if (learnval == 0 && id == MAC_PROP_LDECAY)
3059 return (EINVAL);
3060 if (id == MAC_PROP_LLIMIT)
3061 mip->mi_llimit = learnval;
3062 else
3063 mip->mi_ldecay = learnval;
3064 err = 0;
3065 break;
3066 }
3067
3068 default:
3069 /* For other driver properties, call driver's callback */
3070 if (mip->mi_callbacks->mc_callbacks & MC_SETPROP) {
3071 err = mip->mi_callbacks->mc_setprop(mip->mi_driver,
3072 name, id, valsize, val);
3073 }
3074 }
3075 return (err);
3076 }
3077
3078 /*
3079 * mac_get_prop() gets MAC or device driver properties.
3080 *
3081 * If the property is a driver property, mac_get_prop() calls driver's callback
3082 * entry point to get it.
3083 * If the property is a MAC property, mac_get_prop() invokes mac_get_resources()
3084 * which returns the cached value in mac_impl_t.
3085 */
3086 int
3087 mac_get_prop(mac_handle_t mh, mac_prop_id_t id, char *name, void *val,
3163 mac_rxavail_get(mh) : mac_txavail_get(mh);
3164 bcopy(&rings, val, sizeof (uint_t));
3165 return (0);
3166
3167 case MAC_PROP_MAX_RXHWCLNT_AVAIL:
3168 case MAC_PROP_MAX_TXHWCLNT_AVAIL:
3169 ASSERT(valsize >= sizeof (uint_t));
3170 vlinks = id == MAC_PROP_MAX_RXHWCLNT_AVAIL ?
3171 mac_rxhwlnksavail_get(mh) : mac_txhwlnksavail_get(mh);
3172 bcopy(&vlinks, val, sizeof (uint_t));
3173 return (0);
3174
3175 case MAC_PROP_RXRINGSRANGE:
3176 case MAC_PROP_TXRINGSRANGE:
3177 /*
3178 * The value for these properties are returned through
3179 * the MAC_PROP_RESOURCE property.
3180 */
3181 return (0);
3182
3183 default:
3184 break;
3185
3186 }
3187
3188 /* If driver property, request from driver */
3189 if (mip->mi_callbacks->mc_callbacks & MC_GETPROP) {
3190 err = mip->mi_callbacks->mc_getprop(mip->mi_driver, name, id,
3191 valsize, val);
3192 }
3193
3194 return (err);
3195 }
3196
3197 /*
3198 * Helper function to initialize the range structure for use in
3199 * mac_get_prop. If the type can be other than uint32, we can
3200 * pass that as an arg.
3201 */
3202 static void
3316 /*
3317 * doesn't support groups or
3318 * rings
3319 */
3320 range->mpr_count = 0;
3321 } else {
3322 /*
3323 * -1 because we have to leave out the
3324 * default ring.
3325 */
3326 _mac_set_range(range, 1, max - 1);
3327 }
3328 }
3329 }
3330 return (0);
3331
3332 case MAC_PROP_STATUS:
3333 if (perm != NULL)
3334 *perm = MAC_PROP_PERM_READ;
3335 return (0);
3336 }
3337
3338 /*
3339 * Get the property info from the driver if it implements the
3340 * property info entry point.
3341 */
3342 bzero(&state, sizeof (state));
3343
3344 if (mip->mi_callbacks->mc_callbacks & MC_PROPINFO) {
3345 state.pr_default = default_val;
3346 state.pr_default_size = default_size;
3347
3348 /*
3349 * The caller specifies the maximum number of ranges
3350 * it can accomodate using mpr_count. We don't touch
3351 * this value until the driver returns from its
3352 * mc_propinfo() callback, and ensure we don't exceed
3353 * this number of range as the driver defines
3354 * supported range from its mc_propinfo().
3355 *
|
2972 minsize = sizeof (wl_ess_list_t);
2973 break;
2974 case MAC_PROP_WL_KEY_TAB:
2975 minsize = sizeof (wl_wep_key_tab_t);
2976 break;
2977 case MAC_PROP_WL_CREATE_IBSS:
2978 minsize = sizeof (wl_create_ibss_t);
2979 break;
2980 case MAC_PROP_WL_SETOPTIE:
2981 minsize = sizeof (wl_wpa_ie_t);
2982 break;
2983 case MAC_PROP_WL_DELKEY:
2984 minsize = sizeof (wl_del_key_t);
2985 break;
2986 case MAC_PROP_WL_KEY:
2987 minsize = sizeof (wl_key_t);
2988 break;
2989 case MAC_PROP_WL_MLME:
2990 minsize = sizeof (wl_mlme_t);
2991 break;
2992 case MAC_PROP_MACADDRESS:
2993 minsize = sizeof (mac_addrprop_t);
2994 }
2995
2996 return (valsize >= minsize);
2997 }
2998
2999 /*
3000 * mac_set_prop() sets MAC or hardware driver properties:
3001 *
3002 * - MAC-managed properties such as resource properties include maxbw,
3003 * priority, and cpu binding list, as well as the default port VID
3004 * used by bridging. These properties are consumed by the MAC layer
3005 * itself and not passed down to the driver. For resource control
3006 * properties, this function invokes mac_set_resources() which will
3007 * cache the property value in mac_impl_t and may call
3008 * mac_client_set_resource() to update property value of the primary
3009 * mac client, if it exists.
3010 *
3011 * - Properties which act on the hardware and must be passed to the
3012 * driver, such as MTU, through the driver's mc_setprop() entry point.
3013 */
3050 }
3051
3052 case MAC_PROP_LLIMIT:
3053 case MAC_PROP_LDECAY: {
3054 uint32_t learnval;
3055
3056 if (valsize < sizeof (learnval) ||
3057 (mip->mi_state_flags & MIS_IS_VNIC))
3058 return (EINVAL);
3059 bcopy(val, &learnval, sizeof (learnval));
3060 if (learnval == 0 && id == MAC_PROP_LDECAY)
3061 return (EINVAL);
3062 if (id == MAC_PROP_LLIMIT)
3063 mip->mi_llimit = learnval;
3064 else
3065 mip->mi_ldecay = learnval;
3066 err = 0;
3067 break;
3068 }
3069
3070 case MAC_PROP_MACADDRESS: {
3071 mac_addrprop_t *addrprop = val;
3072
3073 if (addrprop->ma_len != mip->mi_type->mt_addr_length)
3074 return (EINVAL);
3075
3076 err = mac_unicast_primary_set(mh, addrprop->ma_addr);
3077 break;
3078 }
3079
3080 default:
3081 /* For other driver properties, call driver's callback */
3082 if (mip->mi_callbacks->mc_callbacks & MC_SETPROP) {
3083 err = mip->mi_callbacks->mc_setprop(mip->mi_driver,
3084 name, id, valsize, val);
3085 }
3086 }
3087 return (err);
3088 }
3089
3090 /*
3091 * mac_get_prop() gets MAC or device driver properties.
3092 *
3093 * If the property is a driver property, mac_get_prop() calls driver's callback
3094 * entry point to get it.
3095 * If the property is a MAC property, mac_get_prop() invokes mac_get_resources()
3096 * which returns the cached value in mac_impl_t.
3097 */
3098 int
3099 mac_get_prop(mac_handle_t mh, mac_prop_id_t id, char *name, void *val,
3175 mac_rxavail_get(mh) : mac_txavail_get(mh);
3176 bcopy(&rings, val, sizeof (uint_t));
3177 return (0);
3178
3179 case MAC_PROP_MAX_RXHWCLNT_AVAIL:
3180 case MAC_PROP_MAX_TXHWCLNT_AVAIL:
3181 ASSERT(valsize >= sizeof (uint_t));
3182 vlinks = id == MAC_PROP_MAX_RXHWCLNT_AVAIL ?
3183 mac_rxhwlnksavail_get(mh) : mac_txhwlnksavail_get(mh);
3184 bcopy(&vlinks, val, sizeof (uint_t));
3185 return (0);
3186
3187 case MAC_PROP_RXRINGSRANGE:
3188 case MAC_PROP_TXRINGSRANGE:
3189 /*
3190 * The value for these properties are returned through
3191 * the MAC_PROP_RESOURCE property.
3192 */
3193 return (0);
3194
3195 case MAC_PROP_MACADDRESS: {
3196 mac_addrprop_t *addrprop = val;
3197
3198 if (valsize < sizeof (mac_addrprop_t))
3199 return (EINVAL);
3200 mac_unicast_primary_get(mh, addrprop->ma_addr);
3201 addrprop->ma_len = mip->mi_type->mt_addr_length;
3202 return (0);
3203 }
3204
3205 default:
3206 break;
3207
3208 }
3209
3210 /* If driver property, request from driver */
3211 if (mip->mi_callbacks->mc_callbacks & MC_GETPROP) {
3212 err = mip->mi_callbacks->mc_getprop(mip->mi_driver, name, id,
3213 valsize, val);
3214 }
3215
3216 return (err);
3217 }
3218
3219 /*
3220 * Helper function to initialize the range structure for use in
3221 * mac_get_prop. If the type can be other than uint32, we can
3222 * pass that as an arg.
3223 */
3224 static void
3338 /*
3339 * doesn't support groups or
3340 * rings
3341 */
3342 range->mpr_count = 0;
3343 } else {
3344 /*
3345 * -1 because we have to leave out the
3346 * default ring.
3347 */
3348 _mac_set_range(range, 1, max - 1);
3349 }
3350 }
3351 }
3352 return (0);
3353
3354 case MAC_PROP_STATUS:
3355 if (perm != NULL)
3356 *perm = MAC_PROP_PERM_READ;
3357 return (0);
3358
3359 case MAC_PROP_MACADDRESS: {
3360 mac_addrprop_t *defaddr = default_val;
3361
3362 if (defaddr != NULL) {
3363 if (default_size < sizeof (mac_addrprop_t))
3364 return (EINVAL);
3365 bcopy(mip->mi_info.mi_unicst_addr, defaddr->ma_addr,
3366 mip->mi_type->mt_addr_length);
3367 defaddr->ma_len = mip->mi_type->mt_addr_length;
3368 }
3369 return (0);
3370 }
3371 }
3372
3373 /*
3374 * Get the property info from the driver if it implements the
3375 * property info entry point.
3376 */
3377 bzero(&state, sizeof (state));
3378
3379 if (mip->mi_callbacks->mc_callbacks & MC_PROPINFO) {
3380 state.pr_default = default_val;
3381 state.pr_default_size = default_size;
3382
3383 /*
3384 * The caller specifies the maximum number of ranges
3385 * it can accomodate using mpr_count. We don't touch
3386 * this value until the driver returns from its
3387 * mc_propinfo() callback, and ensure we don't exceed
3388 * this number of range as the driver defines
3389 * supported range from its mc_propinfo().
3390 *
|