bge_recv2.c revision e7801d59e8ceda0cde8ebdfdddd7582ee2ea96ef
67d1a47ad0082689ff0f6a8396a511767fff2f96Quaker Fang * CDDL HEADER START
67d1a47ad0082689ff0f6a8396a511767fff2f96Quaker Fang * The contents of this file are subject to the terms of the
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * Common Development and Distribution License (the "License").
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * You may not use this file except in compliance with the License.
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * See the License for the specific language governing permissions
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * and limitations under the License.
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * When distributing Covered Code, include this CDDL HEADER in each
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * If applicable, add the following below this CDDL HEADER, with the
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * fields enclosed by brackets "[]" replaced with your own identifying
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * information: Portions Copyright [yyyy] [name of copyright owner]
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * CDDL HEADER END
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * Use is subject to license terms.
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang#pragma ident "%Z%%M% %I% %E% SMI"
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang#define U32TOPTR(x) ((void *)(uintptr_t)(uint32_t)(x))
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang#define PTRTOU32(x) ((uint32_t)(uintptr_t)(void *)(x))
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * ========== RX side routines ==========
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang#define BGE_DBG BGE_DBG_RECV /* debug flag for this code */
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fangstatic void bge_refill(bge_t *bgep, buff_ring_t *brp, sw_rbd_t *srbdp);
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang#pragma inline(bge_refill)
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * Return the specified buffer (srbdp) to the ring it came from (brp).
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * If the driver is compiled with only one buffer ring *and* one
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * return ring, then the buffers must be returned in sequence.
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * In this case, we don't have to consider anything about the
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * buffer at all; we can simply advance the cyclic counter. And
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * we don't even need the refill mutex <rf_lock>, as the caller
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * will already be holding the (one-and-only) <rx_lock>.
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * If the driver supports multiple buffer rings, but only one
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * return ring, the same still applies (to each buffer ring
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang * separately).
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fangbge_refill(bge_t *bgep, buff_ring_t *brp, sw_rbd_t *srbdp)
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fangstatic mblk_t *bge_receive_packet(bge_t *bgep, bge_rbd_t *hw_rbd_p);
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fangbge_receive_packet(bge_t *bgep, bge_rbd_t *hw_rbd_p)
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang switch (hw_rbd.flags & (RBD_FLAG_MINI_RING|RBD_FLAG_JUMBO_RING)) {
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang /* error, this shouldn't happen */
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang BGE_PKTDUMP((bgep, &hw_rbd, NULL, "bad ring flags!"));
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang#endif /* BGE_BUFF_RINGS_USED > 2 */
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang /* error, this shouldn't happen */
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang BGE_PKTDUMP((bgep, &hw_rbd, NULL, "bad ring index!"));
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang /* bogus, drop the packet */
22a84b8d79248a611e4ba663a268d3c4bed054acQuaker Fang BGE_PKTDUMP((bgep, &hw_rbd, srbdp, "bad ring token"));
goto refill;
goto refill;
#ifdef BGE_IPMI_ASF
goto refill;
#ifdef BGE_IPMI_ASF
goto refill;
#ifdef BGE_IPMI_ASF
#ifdef BGE_IPMI_ASF
goto refill;
return (NULL);
#ifdef BGE_IPMI_ASF
#ifdef BGE_IPMI_ASF
pflags = 0;
if (pflags != 0)
return (mp);
return (NULL);
#pragma inline(bge_receive_ring)
static mblk_t *
int recv_cnt = 0;
return (NULL);
return (NULL);
recv_cnt++;
return (head);
ring = 0;
goto restart;