4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * CDDL HEADER START
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * The contents of this file are subject to the terms of the
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * Common Development and Distribution License (the "License").
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * You may not use this file except in compliance with the License.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * See the License for the specific language governing permissions
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * and limitations under the License.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * When distributing Covered Code, include this CDDL HEADER in each
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * If applicable, add the following below this CDDL HEADER, with the
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * fields enclosed by brackets "[]" replaced with your own identifying
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * information: Portions Copyright [yyyy] [name of copyright owner]
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * CDDL HEADER END
aa71ed9349acc5954237c132b9d246f93d204a54Prakash Jalan * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * functions to handle legacy ndd ioctls
4045d94132614e1de2073685a6cdd4fbd86bec33sowministatic int mac_ndd_set_ioctl(mac_impl_t *, mblk_t *, int, int *);
4045d94132614e1de2073685a6cdd4fbd86bec33sowministatic int mac_ndd_get_ioctl(mac_impl_t *, mblk_t *, int, int *);
4045d94132614e1de2073685a6cdd4fbd86bec33sowministatic int mac_ndd_get_names(mac_impl_t *, mblk_t *);
4045d94132614e1de2073685a6cdd4fbd86bec33sowministatic boolean_t mac_add_name(mblk_t *, char *, int);
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * add "<name> (<rwtag>) " into the mblk, allocating more memory if needed.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini flags = (ndd_flags & (MAC_PROP_PERM_WRITE|MAC_PROP_PERM_READ));
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * allocate space for name, <space>, '(', rwtag, ')', and
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * two terminating null chars.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * handle a query for "ndd -get \?". The result is put into mp, and
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * more memory is allocated if needed. The resulting size of the data
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * is returned.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini return (-1);
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini /* first the known ndd mappings */
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini for (i = 0; i < mip->mi_type->mt_mappingcount; i++) {
afdda45f890ee5dfc86e5131a30b11b354d51633Vasumathi Sundaram - Sun Microsystems if ((mip->mi_type->mt_mapping[i].mp_flags & MAC_PROP_MAP_KSTAT)
afdda45f890ee5dfc86e5131a30b11b354d51633Vasumathi Sundaram - Sun Microsystems permflags = MAC_PROP_PERM_READ;
afdda45f890ee5dfc86e5131a30b11b354d51633Vasumathi Sundaram - Sun Microsystems status = mip->mi_callbacks->mc_getprop(mip->mi_driver,
afdda45f890ee5dfc86e5131a30b11b354d51633Vasumathi Sundaram - Sun Microsystems mip->mi_type->mt_mapping[i].mp_name,
afdda45f890ee5dfc86e5131a30b11b354d51633Vasumathi Sundaram - Sun Microsystems mip->mi_type->mt_mapping[i].mp_prop_id,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mip->mi_type->mt_mapping[i].mp_valsize, &value);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mip->mi_type->mt_mapping[i].mp_name, NULL, 0,
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini if (!mac_add_name(mp, mip->mi_type->mt_mapping[i].mp_name,
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini return (-1);
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini /* now the driver's ndd variables */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (mac_prop_info((mac_handle_t)mip, MAC_PROP_PRIVATE,
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini /* skip over the "_" */
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (!mac_add_name(mp, &prop_name[1], permflags))
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini return (-1);
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * Handle legacy ndd ioctls for ND_GET and ND_SET.
4045d94132614e1de2073685a6cdd4fbd86bec33sowminimac_ndd_ioctl(mac_impl_t *mip, queue_t *wq, mblk_t *mp)
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini err = mac_ndd_set_ioctl(mip, mp, iocp->ioc_count, &rval);
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini err = mac_ndd_get_ioctl(mip, mp, iocp->ioc_count, &rval);
4045d94132614e1de2073685a6cdd4fbd86bec33sowminimac_ndd_get_ioctl(mac_impl_t *mip, mblk_t *mp, int avail, int *rval)
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini mp1 = allocb(avail, BPRI_HI); /* the returned buffer */
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * handle "ndd -get <..> \?" queries.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * need more user buffer space. Return as many
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * mblks as will fit and return the needed
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * buffer size in ioc_rval.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini ASSERT(mip->mi_callbacks->mc_callbacks & MC_GETPROP);
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini /* first lookup ndd <-> public property mapping */
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini for (i = 0; i < mip->mi_type->mt_mappingcount; i++) {
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini if (strcmp(name, mip->mi_type->mt_mapping[i].mp_name) != 0)
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini if ((mip->mi_type->mt_mapping[i].mp_flags & MAC_PROP_MAP_KSTAT)
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * ether_stats are all always KSTAT_DATA_UINT32
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini status = mip->mi_callbacks->mc_getprop(mip->mi_driver,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer name, mip->mi_type->mt_mapping[i].mp_prop_id,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mip->mi_type->mt_mapping[i].mp_valsize, value);
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * The only uint64_t is for speed, which is
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * converted to Mbps in ndd reports.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * could not find a public property. try the private prop route
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini * where all string processing will be done by the driver.
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini (void) snprintf(priv_name, sizeof (priv_name), "_%s", name);
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini status = mip->mi_callbacks->mc_getprop(mip->mi_driver, priv_name,
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini size_out += strnlen((const char *)mp1->b_rptr, avail);
4045d94132614e1de2073685a6cdd4fbd86bec33sowminimac_ndd_set_ioctl(mac_impl_t *mip, mblk_t *mp, int avail, int *rval)
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini ((status = secpolicy_net_config(iocp->ioc_cr, B_FALSE)) != 0)))
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini /* first lookup ndd <-> public property mapping */
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini for (i = 0; i < mip->mi_type->mt_mappingcount; i++) {
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini if (strcmp(name, mip->mi_type->mt_mapping[i].mp_name) != 0)
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini if (mip->mi_type->mt_mapping[i].mp_flags & MAC_PROP_MAP_KSTAT)
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini if (new_value > mip->mi_type->mt_mapping[i].mp_maxval ||
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini new_value < mip->mi_type->mt_mapping[i].mp_minval ||
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini (mip->mi_type->mt_mapping[i].mp_flags & MAC_PROP_PERM_WRITE)
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini status = mip->mi_callbacks->mc_setprop(mip->mi_driver,
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini mip->mi_type->mt_mapping[i].mp_valsize, (const void *)vp);
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini (void) snprintf(priv_name, sizeof (priv_name), "_%s", name);