tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: NET_MPSAFE support for ifmedia / mii



Hi.

> In addition to that fix, I want to make one additional small tweak (and have also fixed a couple of issues with usbnet-based drivers).  New diff at http://www.netbsd.org/~thorpej/ifmedia-mpsafe-diff.txt.
> 
> MD5 (ifmedia-mpsafe-diff.txt) = c1d085c51a2dd474443ae1c1fcf0fabc
In the diff:

> +#define	IFMEDIA_IOCTL_LOCK(ifm)						\
> +do {									\
> +	if (ifmedia_islegacy(ifm))					\
> +		ifmedia_lock_for_legacy(ifm);				\
> +	else								\
> +		ifmedia_lock(ifm);					\
> +} while (/*CONSTCOND*/0)
> +
> +#define	IFMEDIA_IOCTL_UNLOCK(ifm)					\
> +do {									\
> +	if (ifmedia_islegacy(ifm))					\
> +		ifmedia_unlock_for_legacy(ifm);				\
> +	else								\
> +		ifmedia_unlock(ifm);					\
> +} while (/*CONSTCOND*/0)
> +
>  /*
>   * Device-independent media ioctl support function.
>   */
> @@ -280,7 +436,9 @@ ifmedia_ioctl_locked(struct ifnet *ifp, 
>  		u_int oldmedia;
>  		u_int newmedia = ifr->ifr_media;
>  
> -		match = ifmedia_match(ifm, newmedia, ifm->ifm_mask);
> +		IFMEDIA_IOCTL_LOCK(ifm);
> +
> +		match = ifmedia_match_locked(ifm, newmedia, ifm->ifm_mask);
>  		if (match == NULL) {
>  #ifdef IFMEDIA_DEBUG
>  			if (ifmedia_debug) {
> @@ -288,6 +446,7 @@ ifmedia_ioctl_locked(struct ifnet *ifp, 
>  				    "0x%08x\n", newmedia);
>  			}
>  #endif
> +			IFMEDIA_IOCTL_UNLOCK(ifm);
>  			return EINVAL;
>  		}
>  

ifmedia_ioctl_locked() calls IFMEDIA_IOCTL_LOCK(). Usually *_lock"ed"()
is used for already locked resource. I think it would be good to rename
those functions more understandable.

Regards.

-- 
-----------------------------------------------
                SAITOH Masanobu (msaitoh%execsw.org@localhost
                                 msaitoh%netbsd.org@localhost)


Home | Main Index | Thread Index | Old Index