From sacadmin Sat Jun  4 12:58:22 2005
Received: from phorcys.East.Sun.COM (phorcys.East.Sun.COM [129.148.174.143])
	by sac.sfbay.sun.com (8.12.9+Sun/8.12.9) with ESMTP id j54JwMs0017150
	for <psarc@sac.sfbay.sun.com>; Sat, 4 Jun 2005 12:58:22 -0700 (PDT)
Received: from phorcys.East.Sun.COM (localhost [127.0.0.1])
	by phorcys.East.Sun.COM (8.13.4+Sun/8.13.4) with ESMTP id j54JvwZU016631;
	Sat, 4 Jun 2005 15:57:58 -0400 (EDT)
Received: (from carlsonj@localhost)
	by phorcys.East.Sun.COM (8.13.4+Sun/8.13.4/Submit) id j54JvwV6016628;
	Sat, 4 Jun 2005 15:57:58 -0400 (EDT)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <17058.1990.523888.34901@gargle.gargle.HOWL>
Date: Sat, 4 Jun 2005 15:57:58 -0400
From: James Carlson <james.d.carlson@Sun.COM>
To: psarc@sac.sfbay.sun.com
cc: Peter.Memishian@Sun.COM, clearview-iteam@Sun.COM
Subject: 2005/358 Nemo Transmit Pointers
X-Mailer: VM 7.01 under Emacs 21.3.1
Status: RO
Content-Length: 3576

I'm sponsoring this fast-track request for Peter Memishian and the
Clearview I-team.  The timer is set to 06/11/2005.


Overview
========

  This case proposes changes to the Nemo mac_tx_get() interface, in
  order to fix several key problems.  The interface is currently
  Project Private, but given that it was included in "Nemo -
  a.k.a. GLD v3" (PSARC 2004/571), we felt it appropriate to notify
  PSARC of the change.

  Patch binding is requested.

Problem Details
===============

  The current mac_tx_get() interface is declared as:

 	void mac_tx_get(mac_handle_t mh, mac_tx_t *txp, void **argp);

  ... and is defined to return the underlying transmit function and a
  pointer to an opaque argument to pass to the Nemo driver associated
  with the provided mac_handle_t.

  This is problematic for two reasons:

	* The consumers of mac_tx_get() are heavily multithreaded and
	  make use of the information provided by mac_tx_get() in
	  performance-critical codepaths, such as packet transmit.
	  However, because the transmit function and its argument are set
	  independently by mac_tx_get(), locks are currently required to
	  ensure that they appear to be set atomically.

	* Since mac_tx_get() does not internally check whether the MAC is
	  in promiscuous-mode, each caller must do this -- leading to
	  repeated code blocks like:

                if (mac_promisc_get(dip->di_mh, MAC_PROMISC)) {
                        dip->di_tx = mac_txloop;
                        dip->di_tx_arg = dip->di_mh;
                } else {
                        mac_tx_get(dip->di_mh, &dip->di_tx, &dip->di_tx_arg);
                }

	  In addition, the lack of centralized handling of promiscuous-mode
	  in mac_tx_get() prevents additional debugging logic from being
	  added, such as asserting that there are indeed promiscuous
	  listeners when promiscuous mode is enabled.

  To fix these problems, we propose to introduce a new structure that
  contains both the transmit function and its associated argument:

	typedef struct mac_txinfo_s {
	        mac_tx_t	mt_fn;
	        void		*mt_arg;
	} mac_txinfo_t;

  When the mac_handle_t is created, two of these structures will be
  allocated and initialized: one for normal transmit, and one for loopback
  transmit.  These structures will remain constant over the lifetime of
  the mac_handle_t, and will only be destroyed when the mac_handle_t
  is destroyed.

  With the above in-place, mac_tx_get() is simply changed to return the
  address of the appropriate transmit information structure, depending on
  whether or not the mac_handle_t is in promiscuous mode:

 	const mac_txinfo_t *mac_tx_get(mac_handle_t mh);

  Thus, the earlier block of code is reduced to simply:

	dip->di_txinfo = mac_tx_get(dip->di_mh)

  Since we assume throughout the kernel that assignment of pointer-sized
  (or smaller) values is atomic, this allows us to keep our transmit
  functions lockless, and also preserve the tail-call optimization where
  applicable -- e.g., here's the new dls_tx():

	mblk_t *
	dls_tx(dls_channel_t dc, mblk_t *mp)
	{
	        mac_txinfo_t *mtp = ((dls_impl_t *)dc)->di_txinfo;
	
	        return (mtp->mt_fn(mtp->mt_arg, mp));
	}

Interface Changes
=================

  mac_txinfo_t: added:

	typedef struct mac_txinfo_s {
	        mac_tx_t	mt_fn;
	        void		*mt_arg;
	} mac_txinfo_t;

  mac_tx_get: changed from:

	void mac_tx_get(mac_handle_t mh, mac_tx_t *txp, void **argp);

     ... to:

 	const mac_txinfo_t *mac_tx_get(mac_handle_t mh);

  Again, all changes are to Project Private interfaces.

From sacadmin Tue Jun 14 16:21:13 2005
Received: from phorcys.East.Sun.COM (phorcys.East.Sun.COM [129.148.174.143])
	by sac.sfbay.sun.com (8.12.9+Sun/8.12.9) with ESMTP id j5ENLDs0024796
	for <psarc@sac.sfbay.sun.com>; Tue, 14 Jun 2005 16:21:13 -0700 (PDT)
Received: from phorcys.East.Sun.COM (localhost [127.0.0.1])
	by phorcys.East.Sun.COM (8.13.4+Sun/8.13.4) with ESMTP id j5ENKhgu020886;
	Tue, 14 Jun 2005 19:20:43 -0400 (EDT)
Received: (from carlsonj@localhost)
	by phorcys.East.Sun.COM (8.13.4+Sun/8.13.4/Submit) id j5ENKhZk020883;
	Tue, 14 Jun 2005 19:20:43 -0400 (EDT)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <17071.26187.838947.518012@gargle.gargle.HOWL>
Date: Tue, 14 Jun 2005 19:20:43 -0400
From: James Carlson <james.d.carlson@Sun.COM>
To: psarc@sac.sfbay.sun.com
cc: Peter.Memishian@Sun.COM, clearview-iteam@Sun.COM
Subject: 2005/358 Nemo Transmit Pointers
X-Mailer: VM 7.01 under Emacs 21.3.1
Status: RO
Content-Length: 307

This case timed out three days ago without comment.  I'm marking it as
"approved."

-- 
James Carlson, KISS Network                    <james.d.carlson@sun.com>
Sun Microsystems / 1 Network Drive         71.234W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.497N   Fax +1 781 442 1677

From sacadmin Tue Jun 14 19:09:37 2005
Received: from triplex.East.Sun.COM (triplex.East.Sun.COM [129.148.174.104])
	by sac.sfbay.sun.com (8.12.9+Sun/8.12.9) with ESMTP id j5F29as0007961
	for <psarc@sac.sfbay.sun.com>; Tue, 14 Jun 2005 19:09:36 -0700 (PDT)
Received: from triplex.East.Sun.COM (localhost [127.0.0.1])
	by triplex.East.Sun.COM (8.13.4+Sun/8.13.4) with ESMTP id j5F2BaCZ134897;
	Tue, 14 Jun 2005 22:11:36 -0400 (EDT)
Received: (from meem@localhost)
	by triplex.East.Sun.COM (8.13.4+Sun/8.13.4/Submit) id j5F2BaWm134894;
	Tue, 14 Jun 2005 22:11:36 -0400 (EDT)
From: Peter Memishian <peter.memishian@Sun.COM>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <17071.36439.920934.54301@gargle.gargle.HOWL>
Date: Tue, 14 Jun 2005 22:11:35 -0400
To: James Carlson <James.D.Carlson@Sun.COM>
Cc: psarc@sac.sfbay.sun.com, Peter.Memishian@Sun.COM, clearview-iteam@Sun.COM
Subject: re: 2005/358 Nemo Transmit Pointers
In-Reply-To: <17071.26187.838947.518012@gargle.gargle.HOWL>
References: <17071.26187.838947.518012@gargle.gargle.HOWL>
X-Mailer: VM 7.17 under 21.4 (patch 15) "Security Through Obscurity" XEmacs Lucid
Status: RO
Content-Length: 116


 > This case timed out three days ago without comment.  I'm marking it as
 > "approved."

great, thanks!

-- 
meem

