[ofa-general] [PATCH] libibumad: support for new pkey enabled user_mad API

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Thu Nov 1 04:30:20 PDT 2007


Sasha Khapyorsky wrote:
> On 12:38 Thu 01 Nov     , Sasha Khapyorsky wrote:
>   
>> On 11:19 Thu 01 Nov     , Yevgeny Kliteynik wrote:
>>     
>>>>  +	if (abi_version > 5)
>>>> +		new_user_mad_api = 1;
>>>> +	else {
>>>> +		int ret = ioctl(fd, IB_USER_MAD_ENABLE_PKEY, NULL);
>>>>   
>>>>         
>>>  I got (ret = -1) and (errno = 515)
>>>       
>> It is ENOIOCTLCMD, and it is correct value when unlocked_ioctl() method
>> is not defined by driver. So I think we need to handle this one too.
>>
>>     
>>>> +		if (ret == 0)
>>>> +			new_user_mad_api = 1;
>>>> +		else if (ret < 0 && errno == EINVAL)
>>>> +			new_user_mad_api = 0;
>>>>   +		else {
>>>>   
>>>>         
>>>  So eventually I got here.
>>>  I have kernel 2.6.9-42.
>>>       
>> I will send update soon.
>>     
>
> For me it looks that best we can do is to just remove any errno checks -
> as below.
>   
I'm all for it.

-- Yevgeny

> Sasha
>
>
> >From fe395b0c3de4dbbe69c31b9d97818c81ac76a99c Mon Sep 17 00:00:00 2001
> From: Sasha Khapyorsky <sashak at voltaire.com>
> Date: Thu, 1 Nov 2007 13:52:06 +0200
> Subject: [PATCH] libibumad: don't check errno when pkey enabling API ioctl() fails
>
> With some old kernel ioctl() returns 515 (ENOIOCTLCMD), which is not
> defined in userspace at all. OTOH the usage of this ioctl() is hidden
> inside libibumad library where failure scenarios are limited - it is
> likely enough to just refer return status and don't analyze errno value
> at all.
>
> Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
> ---
>  libibumad/src/umad.c |   16 +++-------------
>  1 files changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/libibumad/src/umad.c b/libibumad/src/umad.c
> index b63f220..1012695 100644
> --- a/libibumad/src/umad.c
> +++ b/libibumad/src/umad.c
> @@ -597,20 +597,10 @@ umad_open_port(char *ca_name, int portnum)
>  		return -EIO;
>  	}
>  
> -	if (abi_version > 5)
> +	if (abi_version > 5 || !ioctl(fd, IB_USER_MAD_ENABLE_PKEY, NULL))
>  		new_user_mad_api = 1;
> -	else {
> -		int ret = ioctl(fd, IB_USER_MAD_ENABLE_PKEY, NULL);
> -		if (ret == 0)
> -			new_user_mad_api = 1;
> -		else if (ret < 0 && errno == EINVAL)
> -			new_user_mad_api = 0;
> -		else {
> -			close(fd);
> -			IBWARN("cannot detect is user_mad P_Key enabled API supported.");
> -			return ret;
> -		}
> -	}
> +	else
> +		new_user_mad_api = 0;
>  
>  	DEBUG("opened %s fd %d portid %d", dev_file, fd, umad_id);
>  	return fd;
>   



More information about the general mailing list