d62bc4badc1c1f1549c961cfb8b420e650e1272byz * CDDL HEADER START
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * The contents of this file are subject to the terms of the
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Common Development and Distribution License (the "License").
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * You may not use this file except in compliance with the License.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * See the License for the specific language governing permissions
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * and limitations under the License.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * When distributing Covered Code, include this CDDL HEADER in each
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * If applicable, add the following below this CDDL HEADER, with the
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * fields enclosed by brackets "[]" replaced with your own identifying
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * information: Portions Copyright [yyyy] [name of copyright owner]
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * CDDL HEADER END
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Use is subject to license terms.
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * This function is a generic open(9E) entry point into the softmac for
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * both the softmac module and the softmac driver.
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhoustatic int softmac_cmn_open(queue_t *, dev_t *, int, int, cred_t *);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * The following softmac_mod_xxx() functions are (9E) entry point functions for
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * the softmac module.
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhoustatic void softmac_mod_rput(queue_t *, mblk_t *);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhoustatic void softmac_mod_wput(queue_t *, mblk_t *);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * The following softmac_drv_xxx() functions are (9E) entry point functions for
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * the softmac driver.
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhoustatic int softmac_drv_open(queue_t *, dev_t *, int, int, cred_t *);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhoustatic void softmac_drv_wput(queue_t *, mblk_t *);
d62bc4badc1c1f1549c961cfb8b420e650e1272byzstatic int softmac_attach(dev_info_t *, ddi_attach_cmd_t);
d62bc4badc1c1f1549c961cfb8b420e650e1272byzstatic int softmac_detach(dev_info_t *, ddi_detach_cmd_t);
d62bc4badc1c1f1549c961cfb8b420e650e1272byzstatic int softmac_info(dev_info_t *, ddi_info_cmd_t, void *, void **);
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * hi-water mark is 1 because of the flow control mechanism implemented in
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * dld. Refer to the comments in dld_str.c for details.
d62bc4badc1c1f1549c961cfb8b420e650e1272byzDDI_DEFINE_STREAM_OPS(softmac_ops, nulldev, nulldev, softmac_attach,
193974072f41a843678abf5f61979c748687e66bSherry Moore softmac_detach, nodev, softmac_info, D_MP, &softmac_tab,
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou NULL, NULL, softmac_drv_open, softmac_drv_close, NULL,
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou (pfi_t)softmac_drv_wput, (pfi_t)softmac_drv_wsrv, NULL, NULL, NULL,
d62bc4badc1c1f1549c961cfb8b420e650e1272byz "softmac driver",
d62bc4badc1c1f1549c961cfb8b420e650e1272byz "softmac module",
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkstatic void softmac_dedicated_rx(void *, mac_resource_handle_t, mblk_t *,
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhousoftmac_upper_constructor(void *buf, void *arg, int kmflag)
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou mutex_init(&sup->su_mutex, NULL, MUTEX_DEFAULT, NULL);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou mutex_init(&sup->su_disp_mutex, NULL, MUTEX_DEFAULT, NULL);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou cv_init(&sup->su_disp_cv, NULL, CV_DEFAULT, NULL);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou list_create(&sup->su_req_list, sizeof (softmac_switch_req_t),
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou offsetof(softmac_switch_req_t, ssq_req_list_node));
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou ASSERT(sup->su_pending_head == NULL && sup->su_pending_tail == NULL);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou softmac_upper_cachep = kmem_cache_create("softmac_upper_cache",
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou sizeof (softmac_upper_t), 0, softmac_upper_constructor,
d62bc4badc1c1f1549c961cfb8b420e650e1272byz return (0);
d62bc4badc1c1f1549c961cfb8b420e650e1272byz return (0);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhousoftmac_cmn_open(queue_t *rq, dev_t *devp, int flag, int sflag, cred_t *credp)
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * This is a self-cloning driver so that each queue should only
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * get opened once.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * This is the softmac module pushed over an underlying
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * legacy device. Initialize the lower structure.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz if ((slp = kmem_zalloc(sizeof (*slp), KM_NOSLEEP)) == NULL)
d62bc4badc1c1f1549c961cfb8b420e650e1272byz return (0);
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Regular device open of a softmac DLPI node. We modify
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * the queues' q_qinfo pointer such that all future STREAMS
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * operations will go through another set of entry points
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou return (softmac_drv_open(rq, devp, flag, sflag, credp));
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Call the appropriate delete routine depending on whether this is
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * a module or device.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz return (0);
d62bc4badc1c1f1549c961cfb8b420e650e1272byzstatic void
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * This is the softmac module.
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * If sl_rxinfo is non-NULL. This is dedicated-lower-stream
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * created for fastpath. Directly call the rx callback.
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * A shared-lower-stream. Some driver starts to send up
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * packets even it not in the DL_IDLE state, where
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * sl_softmac is not set yet. Drop the packet in this case.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * If this message is looped back from the legacy devices,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * drop it as the Nemo framework will be responsible for
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * looping it back by the mac_txloop() function.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * This is the most common case.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz /*FALLTHROUGH*/
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou softmac_rput_process_notdata(rq, slp->sl_sup, mp);
d62bc4badc1c1f1549c961cfb8b420e650e1272byzstatic void
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * This is the softmac module
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Assign the devname and perstream handle of the
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * specific lower stream and return it as a part
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * of the ioctl.
d62bc4badc1c1f1549c961cfb8b420e650e1272byzstatic void
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * This is the softmac module
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Inform that the tx resource is available; mac_tx_update() will
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * inform all the upper streams sharing this lower stream.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz/* ARGSUSED */
d62bc4badc1c1f1549c961cfb8b420e650e1272byz/* ARGSUSED */
d62bc4badc1c1f1549c961cfb8b420e650e1272byzsoftmac_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhousoftmac_dedicated_rx(void *arg, mac_resource_handle_t mrh, mblk_t *mp,
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhousoftmac_drv_open(queue_t *rq, dev_t *devp, int flag, int sflag, cred_t *credp)
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * This is a softmac device created for a legacy device, find the
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * associated softmac and initialize the softmac_upper_t structure.
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou sup = kmem_cache_alloc(softmac_upper_cachep, KM_NOSLEEP);
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou if ((sup->su_tx_flow_mp = allocb(1, BPRI_HI)) == NULL) {
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou sup->su_direct_rxinfo.slr_rx = softmac_dedicated_rx;
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * Wait until the pending request are processed by the worker thread.
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou prim = ((union DL_primitives *)mp->b_rptr)->dl_primitive;
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * Bump su_tx_inprocess so that su_mode won't change.
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou } else if (sup->su_tx_busy && SOFTMAC_CANPUTNEXT(sup->su_slp->sl_wq)) {
5d460eafffba936e81c4dd5ebe0f59b238f09121Cathy Zhou * The flow-conctol of the dedicated-lower-stream is
79eeb64527c881659e23b60088c32ae3736a7a2cCathy Zhou * relieved. If DLD_CAPAB_DIRECT is enabled, call tx_notify
79eeb64527c881659e23b60088c32ae3736a7a2cCathy Zhou * callback to relieve the flow-control of the specific client,
79eeb64527c881659e23b60088c32ae3736a7a2cCathy Zhou * otherwise relieve the flow-control of all the upper-stream
79eeb64527c881659e23b60088c32ae3736a7a2cCathy Zhou * using the traditional STREAM mechanism.