components/open-fabrics/libmlx4/patches/base.patch
changeset 715 eed3ed08f692
parent 673 bb9df3c906be
child 817 f45ca7242301
equal deleted inserted replaced
714:b205ca9f0d84 715:eed3ed08f692
    25  #define MLX4_UVERBS_MAX_ABI_VERSION	3
    25  #define MLX4_UVERBS_MAX_ABI_VERSION	3
    26  
    26  
    27 diff -r -u /tmp/839450/libmlx4-1.0.1/src/verbs.c libmlx4-1.0.1/src/verbs.c
    27 diff -r -u /tmp/839450/libmlx4-1.0.1/src/verbs.c libmlx4-1.0.1/src/verbs.c
    28 --- /tmp/839450/libmlx4-1.0.1/src/verbs.c	Thu Mar 10 04:48:34 2011
    28 --- /tmp/839450/libmlx4-1.0.1/src/verbs.c	Thu Mar 10 04:48:34 2011
    29 +++ libmlx4-1.0.1/src/verbs.c	Fri Mar 11 14:40:18 2011
    29 +++ libmlx4-1.0.1/src/verbs.c	Fri Mar 11 14:40:18 2011
    30 @@ -56,6 +56,15 @@
    30 @@ -56,6 +56,14 @@
    31  	if (ret)
    31  	if (ret)
    32  		return ret;
    32  		return ret;
    33  
    33  
    34 +#if defined(__SVR4) && defined(__sun)
    34 +#if defined(__SVR4) && defined(__sun)
    35 +	/*
    35 +	/*
    37 +	 * we need to report the max as actual max  less 1. In OFED this is
    37 +	 * we need to report the max as actual max  less 1. In OFED this is
    38 +	 * done in the HCA driver.
    38 +	 * done in the HCA driver.
    39 +	 */
    39 +	 */
    40 +	attr->max_srq_wr -=1;
    40 +	attr->max_srq_wr -=1;
    41 +#endif
    41 +#endif
    42 +
       
    43  	major     = (raw_fw_ver >> 32) & 0xffff;
    42  	major     = (raw_fw_ver >> 32) & 0xffff;
    44  	minor     = (raw_fw_ver >> 16) & 0xffff;
    43  	minor     = (raw_fw_ver >> 16) & 0xffff;
    45  	sub_minor = raw_fw_ver & 0xffff;
    44  	sub_minor = raw_fw_ver & 0xffff;
    46 @@ -79,6 +88,9 @@
    45 @@ -79,6 +87,9 @@
    47  	struct ibv_alloc_pd       cmd;
    46  	struct ibv_alloc_pd       cmd;
    48  	struct mlx4_alloc_pd_resp resp;
    47  	struct mlx4_alloc_pd_resp resp;
    49  	struct mlx4_pd		 *pd;
    48  	struct mlx4_pd		 *pd;
    50 +#if defined(__SVR4) && defined(__sun)
    49 +#if defined(__SVR4) && defined(__sun)
    51 +	mlnx_umap_pd_data_out_t   *mdd;
    50 +	mlnx_umap_pd_data_out_t   *mdd;
    52 +#endif
    51 +#endif
    53  
    52  
    54  	pd = malloc(sizeof *pd);
    53  	pd = malloc(sizeof *pd);
    55  	if (!pd)
    54  	if (!pd)
    56 @@ -90,7 +102,16 @@
    55 @@ -90,7 +101,16 @@
    57  		return NULL;
    56  		return NULL;
    58  	}
    57  	}
    59  
    58  
    60 +#if defined(__SVR4) && defined(__sun)
    59 +#if defined(__SVR4) && defined(__sun)
    61 +	/*
    60 +	/*
    62 +	 * The kernel driver passes back the PD table index as opaque data.  This
    61 +	 * kernel driver passes back the PD table index as opaque data.  This
    63 +	 * index is required for specifying the PD in user space address vectors.
    62 +	 * is required for specifying the PD in user space address vectors.
    64 +	 */
    63 +	 */
    65 +	mdd     = (mlnx_umap_pd_data_out_t *) &resp.ibv_resp.drv_out;
    64 +	mdd     = (mlnx_umap_pd_data_out_t *) &resp.ibv_resp.drv_out;
    66 +	pd->pdn = mdd->mpd_pdnum;
    65 +	pd->pdn = mdd->mpd_pdnum;
    67 +#else
    66 +#else
    68  	pd->pdn = resp.pdn;
    67  	pd->pdn = resp.pdn;
    69 +#endif
    68 +#endif
    70  
    69  
    71  	return &pd->ibv_pd;
    70  	return &pd->ibv_pd;
    72  }
    71  }
    73 @@ -168,6 +189,10 @@
    72 @@ -168,6 +188,10 @@
    74  	struct mlx4_create_cq_resp resp;
    73  	struct mlx4_create_cq_resp resp;
    75  	struct mlx4_cq		  *cq;
    74  	struct mlx4_cq		  *cq;
    76  	int			   ret;
    75  	int			   ret;
    77 +#if defined(__SVR4) && defined(__sun)
    76 +#if defined(__SVR4) && defined(__sun)
    78 +	void                      *cqbuf;
    77 +	void                      *cqbuf;
    79 +	mlnx_umap_cq_data_out_t   *mdd;
    78 +	mlnx_umap_cq_data_out_t   *mdd;
    80 +#endif
    79 +#endif
    81  
    80  
    82  	/* Sanity check CQ size before proceeding */
    81  	/* Sanity check CQ size before proceeding */
    83  	if (cqe > 0x3fffff)
    82  	if (cqe > 0x3fffff)
    84 @@ -184,7 +209,8 @@
    83 @@ -184,7 +208,8 @@
    85  
    84  
    86  	cqe = align_queue_size(cqe + 1);
    85  	cqe = align_queue_size(cqe + 1);
    87  
    86  
    88 -	if (mlx4_alloc_cq_buf(to_mdev(context->device), &cq->buf, cqe))
    87 -	if (mlx4_alloc_cq_buf(to_mdev(context->device), &cq->buf, cqe))
    89 +#if !(defined(__SVR4) && defined(__sun))
    88 +#if !(defined(__SVR4) && defined(__sun))
    90 +	if (mlx4_alloc_cq_buf((to_mdev(context->device), &cq->buf, cqe))
    89 +	if (mlx4_alloc_cq_buf((to_mdev(context->device), &cq->buf, cqe))
    91  		goto err;
    90  		goto err;
    92  
    91  
    93  	cq->set_ci_db  = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_CQ);
    92  	cq->set_ci_db  = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_CQ);
    94 @@ -198,15 +224,84 @@
    93 @@ -198,15 +223,78 @@
    95  
    94  
    96  	cmd.buf_addr = (uintptr_t) cq->buf.buf;
    95  	cmd.buf_addr = (uintptr_t) cq->buf.buf;
    97  	cmd.db_addr  = (uintptr_t) cq->set_ci_db;
    96  	cmd.db_addr  = (uintptr_t) cq->set_ci_db;
    98 +#else
    97 +#else
    99 +	cq->buf.buf    = NULL;
    98 +	cq->buf.buf    = NULL;
   103 +#endif
   102 +#endif
   104  
   103  
   105  	ret = ibv_cmd_create_cq(context, cqe - 1, channel, comp_vector,
   104  	ret = ibv_cmd_create_cq(context, cqe - 1, channel, comp_vector,
   106  				&cq->ibv_cq, &cmd.ibv_cmd, sizeof cmd,
   105  				&cq->ibv_cq, &cmd.ibv_cmd, sizeof cmd,
   107  				&resp.ibv_resp, sizeof resp);
   106  				&resp.ibv_resp, sizeof resp);
   108 +
   107 +#if defined(__SVR4) && defined(__sun)
   109 +#if defined(__SVR4) && defined(__sun)
   108  	if (ret)
   110 +	if (ret) {
       
   111 +		goto err;
   109 +		goto err;
   112 +	}
   110 +#else
   113 +#else
   111 +	if (ret)
   114  	if (ret)
       
   115  		goto err_db;
   112  		goto err_db;
   116 +#endif
   113 +#endif
   117  
   114  
   118  	cq->cqn = resp.cqn;
   115  	cq->cqn = resp.cqn;
   119  
   116  
   130 +	}
   127 +	}
   131 +
   128 +
   132 +        cqbuf = mmap64((void *)0, mdd->mcq_maplen, (PROT_READ | PROT_WRITE),
   129 +        cqbuf = mmap64((void *)0, mdd->mcq_maplen, (PROT_READ | PROT_WRITE),
   133 +                    MAP_SHARED, context->mmap_fd, mdd->mcq_mapoffset);
   130 +                    MAP_SHARED, context->mmap_fd, mdd->mcq_mapoffset);
   134 +
   131 +
   135 +        if (cqbuf == MAP_FAILED) {
   132 +        if (cqbuf == MAP_FAILED)
   136 +                goto err_destroy;
   133 +                goto err_destroy;
   137 +        }
       
   138 +
   134 +
   139 +        /*
   135 +        /*
   140 +         * Extract hardware driver values for the number of CQEs and the
   136 +         * Extract hardware driver values for the number of CQEs and the
   141 +	 * hardware CQ number to use (needed for user space doorbells).
   137 +	 * hardware CQ number to use (needed for user space doorbells).
   142 +         */
   138 +         */
   143 +        cqe            = mdd->mcq_numcqe;
   139 +	cqe            = mdd->mcq_numcqe;
   144 +        cq->cqn        = mdd->mcq_cqnum;
   140 +	cq->cqn        = mdd->mcq_cqnum;
   145 +        cq->buf.buf    = cqbuf;
   141 +	cq->buf.buf    = cqbuf;
   146 +        cq->buf.length = mdd->mcq_maplen;
   142 +	cq->buf.length = mdd->mcq_maplen;
   147 +	cq->ibv_cq.cqe = cqe-1;
   143 +	cq->ibv_cq.cqe = cqe-1;
   148 +
   144 +
   149 +	/*
   145 +	/*
   150 +	 * We map both poll and arm as seperate doorbells (OFED assumes 1 word
   146 +	 * We map both poll and arm as seperate doorbells (OFED assumes 1 word
   151 +	 * offset and just bumpts the address) since Solaris provides a
   147 +	 * offset and just bumpts the address) since Solaris provides a
   154 +	 */
   150 +	 */
   155 +	cq->set_ci_db = mlx4_alloc_db(to_mctx(context),
   151 +	cq->set_ci_db = mlx4_alloc_db(to_mctx(context),
   156 +	                              mdd->mcq_polldbr_mapoffset,
   152 +	                              mdd->mcq_polldbr_mapoffset,
   157 +	                              mdd->mcq_polldbr_maplen,
   153 +	                              mdd->mcq_polldbr_maplen,
   158 +	                              mdd->mcq_polldbr_offset);
   154 +	                              mdd->mcq_polldbr_offset);
   159 +        if (cq->set_ci_db == NULL) {
   155 +        if (cq->set_ci_db == NULL)
   160 +                goto err_buf;
   156 +                goto err_buf;
   161 +        }
       
   162 +
   157 +
   163 +	cq->arm_db = mlx4_alloc_db(to_mctx(context),
   158 +	cq->arm_db = mlx4_alloc_db(to_mctx(context),
   164 +	                           mdd->mcq_armdbr_mapoffset,
   159 +	                           mdd->mcq_armdbr_mapoffset,
   165 +	                           mdd->mcq_armdbr_maplen,
   160 +	                           mdd->mcq_armdbr_maplen,
   166 +	                           mdd->mcq_armdbr_offset);
   161 +	                           mdd->mcq_armdbr_offset);
   167 +        if (cq->arm_db == NULL) {
   162 +        if (cq->arm_db == NULL)
   168 +                goto err_db;
   163 +                goto err_db;
   169 +        }
       
   170 +
   164 +
   171 +	*cq->arm_db    = 0;
   165 +	*cq->arm_db    = 0;
   172 +	cq->arm_sn     = 1;
   166 +	cq->arm_sn     = 1;
   173 +	*cq->set_ci_db = 0;
   167 +	*cq->set_ci_db = 0;
   174 +#endif
   168 +#endif
   175 +
       
   176  	return &cq->ibv_cq;
   169  	return &cq->ibv_cq;
   177  
   170  
   178  err_db:
   171  err_db:
   179 @@ -215,6 +310,22 @@
   172 @@ -215,6 +303,21 @@
   180  err_buf:
   173  err_buf:
   181  	mlx4_free_buf(&cq->buf);
   174  	mlx4_free_buf(&cq->buf);
   182  
   175  
   183 +#if defined(__SVR4) && defined(__sun)
   176 +#if defined(__SVR4) && defined(__sun)
   184 +err_destroy:
   177 +err_destroy:
   193 +	cq->ibv_cq.comp_events_completed = 0;
   186 +	cq->ibv_cq.comp_events_completed = 0;
   194 +	cq->ibv_cq.async_events_completed = 0;
   187 +	cq->ibv_cq.async_events_completed = 0;
   195 +
   188 +
   196 +	ibv_cmd_destroy_cq(&cq->ibv_cq);
   189 +	ibv_cmd_destroy_cq(&cq->ibv_cq);
   197 +#endif
   190 +#endif
   198 +
       
   199  err:
   191  err:
   200  	free(cq);
   192  	free(cq);
   201  
   193  
   202 @@ -225,12 +336,17 @@
   194 @@ -225,12 +328,16 @@
   203  {
   195  {
   204  	struct mlx4_cq *cq = to_mcq(ibcq);
   196  	struct mlx4_cq *cq = to_mcq(ibcq);
   205  	struct mlx4_resize_cq cmd;
   197  	struct mlx4_resize_cq cmd;
   206 +	struct ibv_resize_cq_resp resp;
   198 +	struct ibv_resize_cq_resp resp;
   207  	struct mlx4_buf buf;
   199  	struct mlx4_buf buf;
   209 -
   201 -
   210 +#if defined(__SVR4) && defined(__sun)
   202 +#if defined(__SVR4) && defined(__sun)
   211 +	void			*cqbuf;
   203 +	void			*cqbuf;
   212 +	mlnx_umap_cq_data_out_t	*mdd;
   204 +	mlnx_umap_cq_data_out_t	*mdd;
   213 +#endif
   205 +#endif
   214 +	
       
   215  	/* Sanity check CQ size before proceeding */
   206  	/* Sanity check CQ size before proceeding */
   216  	if (cqe > 0x3fffff)
   207  	if (cqe > 0x3fffff)
   217 -		return EINVAL;
   208 -		return EINVAL;
   218 + 		return EINVAL;
   209 + 		return EINVAL;
   219  
   210  
   220  	pthread_spin_lock(&cq->lock);
   211  	pthread_spin_lock(&cq->lock);
   221  
   212  
   222 @@ -247,32 +363,65 @@
   213 @@ -247,32 +354,76 @@
   223  		goto out;
   214  		goto out;
   224  	}
   215  	}
   225  
   216  
   226 +#if !(defined(__SVR4) && defined(__sun))
   217 +#if !(defined(__SVR4) && defined(__sun))
   227  	ret = mlx4_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe);
   218  	ret = mlx4_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe);
   228  	if (ret)
   219  	if (ret)
   229  		goto out;
   220  		goto out;
   230  
   221 -
   231 -	old_cqe = ibcq->cqe;
   222 -	old_cqe = ibcq->cqe;
   232 -	cmd.buf_addr = (uintptr_t) buf.buf;
   223  	cmd.buf_addr = (uintptr_t) buf.buf;
   233 +        cmd.buf_addr = (uintptr_t) buf.buf;
       
   234 +#endif
   224 +#endif
   235 +        old_cqe = ibcq->cqe;
   225 +        old_cqe = ibcq->cqe;
   236  
   226  
   237  #ifdef IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS
   227  #ifdef IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS
   238 -	{
   228 -	{
   246  #endif
   236  #endif
   247 -	if (ret) {
   237 -	if (ret) {
   248 -		mlx4_free_buf(&buf);
   238 -		mlx4_free_buf(&buf);
   249 +
   239 +
   250 +        if (ret) {
   240 +        if (ret) {
   251 +#if ! (defined(__SVR4) && defined(__sun))
   241 +#if !(defined(__SVR4) && defined(__sun))
   252 +                mlx4_free_buf(&buf);
   242 +                mlx4_free_buf(&buf);
   253 +#endif
       
   254  		goto out;
   243  		goto out;
   255  	}
   244  	}
   256  
   245  
   257 -	mlx4_cq_resize_copy_cqes(cq, buf.buf, old_cqe);
   246 -	mlx4_cq_resize_copy_cqes(cq, buf.buf, old_cqe);
   258 +#if defined(__SVR4) && defined(__sun)
   247 +        mlx4_cq_resize_copy_cqes(cq, buf.buf, old_cqe);
       
   248 +        mlx4_free_buf(&cq->buf);
       
   249 +        cq->buf = buf;
       
   250 +#else
       
   251 +		goto out;
       
   252 +	}
       
   253 +        if (cq->buf.buf != NULL) {
       
   254 +        	buf.buf = malloc(cq->buf.length);
       
   255 +        	if (!buf.buf) {
       
   256 +                	ret = ENOMEM;
       
   257 +                	goto out;
       
   258 +        	}
       
   259  
       
   260 -	mlx4_free_buf(&cq->buf);
       
   261 -	cq->buf = buf;
       
   262 +        	memcpy(buf.buf, cq->buf.buf, cq->buf.length);
       
   263 +        	buf.length =  cq->buf.length;
       
   264 +                ret = munmap((char *)cq->buf.buf, cq->buf.length);
       
   265 +                if (ret) {
       
   266 +                        free(buf.buf);
       
   267 +                        goto out;
       
   268 +                }
       
   269 +        }
   259 +	/*
   270 +	/*
   260 +	 * For Solaris the kernel driver passes back mmap information for
   271 +	 * For Solaris the kernel driver passes back mmap information for
   261 +	 * mapping the CQ memory it allocated.
   272 +	 * mapping the CQ memory it allocated.
   262 +	 */
   273 +	 */
   263 +	mdd = (mlnx_umap_cq_data_out_t *) &resp.drv_out;
   274 +	mdd = (mlnx_umap_cq_data_out_t *) &resp.drv_out;
   266 +		    "rev mismatch (kernel rev=%d)\n", mdd->mcq_rev);
   277 +		    "rev mismatch (kernel rev=%d)\n", mdd->mcq_rev);
   267 +		ret = EINVAL;
   278 +		ret = EINVAL;
   268 +		goto out;
   279 +		goto out;
   269 +	}
   280 +	}
   270  
   281  
   271 -	mlx4_free_buf(&cq->buf);
       
   272 -	cq->buf = buf;
       
   273 +	cqbuf = mmap64((void *)0, mdd->mcq_maplen, (PROT_READ | PROT_WRITE),
   282 +	cqbuf = mmap64((void *)0, mdd->mcq_maplen, (PROT_READ | PROT_WRITE),
   274 +	     MAP_SHARED, ibcq->context->mmap_fd, mdd->mcq_mapoffset);
   283 +	     MAP_SHARED, ibcq->context->mmap_fd, mdd->mcq_mapoffset);
   275  
   284 +
   276 +	if (cqbuf == MAP_FAILED) {
   285 +	if (cqbuf == MAP_FAILED) {
   277 +		ret = EINVAL;
   286 +		ret = EINVAL;
   278 +		goto out;
   287 +		goto out;
   279 +	}
   288 +	}
   280 +#endif
   289 +	cq->buf.buf    = buf.buf;
   281 +
   290 +	cq->buf.length = buf.length;
   282 +        mlx4_cq_resize_copy_cqes(cq, buf.buf, old_cqe);
   291 +	mlx4_cq_resize_copy_cqes(cq, cqbuf, old_cqe);
   283 +
       
   284 +#if !(defined(__SVR4) && defined(__sun))
       
   285 +        mlx4_free_buf(&cq->buf);
       
   286 +#endif
       
   287 +        cq->buf = buf;
       
   288 +
       
   289 +#if defined(__SVR4) && defined(__sun)
       
   290 +	cqe            = mdd->mcq_numcqe;
       
   291 +	cq->cqn        = mdd->mcq_cqnum;
       
   292 +	cq->buf.buf    = cqbuf;
   292 +	cq->buf.buf    = cqbuf;
   293 +	cq->buf.length = mdd->mcq_maplen;
   293 +	cq->buf.length = mdd->mcq_maplen;
   294 +	cq->ibv_cq.cqe = cqe-1;
   294 +	free(buf.buf);
       
   295 +	cq->ibv_cq.cqe =  mdd->mcq_numcqe - 1;
       
   296 +	cq->cqn        = mdd->mcq_cqnum;
   295 +#endif
   297 +#endif
   296  out:
   298  out:
   297  	pthread_spin_unlock(&cq->lock);
   299  	pthread_spin_unlock(&cq->lock);
   298  	return ret;
   300  	return ret;
   299 @@ -287,6 +436,9 @@
   301 @@ -287,6 +438,9 @@
   300  		return ret;
   302  		return ret;
   301  
   303  
   302  	mlx4_free_db(to_mctx(cq->context), MLX4_DB_TYPE_CQ, to_mcq(cq)->set_ci_db);
   304  	mlx4_free_db(to_mctx(cq->context), MLX4_DB_TYPE_CQ, to_mcq(cq)->set_ci_db);
   303 +#if defined(__SVR4) && defined(__sun)
   305 +#if defined(__SVR4) && defined(__sun)
   304 +	mlx4_free_db(to_mctx(cq->context), MLX4_DB_TYPE_CQ, to_mcq(cq)->arm_db);
   306 +	mlx4_free_db(to_mctx(cq->context), MLX4_DB_TYPE_CQ, to_mcq(cq)->arm_db);
   305 +#endif
   307 +#endif
   306  	mlx4_free_buf(&to_mcq(cq)->buf);
   308  	mlx4_free_buf(&to_mcq(cq)->buf);
   307  	free(to_mcq(cq));
   309  	free(to_mcq(cq));
   308  
   310  
   309 @@ -300,6 +452,10 @@
   311 @@ -300,6 +454,10 @@
   310  	struct mlx4_create_srq_resp resp;
   312  	struct mlx4_create_srq_resp resp;
   311  	struct mlx4_srq		   *srq;
   313  	struct mlx4_srq		   *srq;
   312  	int			    ret;
   314  	int			    ret;
   313 +#if defined(__SVR4) && defined(__sun)
   315 +#if defined(__SVR4) && defined(__sun)
   314 +	mlnx_umap_srq_data_out_t   *mdd;
   316 +	mlnx_umap_srq_data_out_t   *mdd;
   315 +	void                       *srqbuf;
   317 +	void                       *srqbuf;
   316 +#endif
   318 +#endif
   317  
   319  
   318  	/* Sanity check SRQ size before proceeding */
   320  	/* Sanity check SRQ size before proceeding */
   319  	if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64)
   321  	if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64)
   320 @@ -312,6 +468,7 @@
   322 @@ -312,6 +470,7 @@
   321  	if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE))
   323  	if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE))
   322  		goto err;
   324  		goto err;
   323  
   325  
   324 +#if !(defined(__SVR4) && defined(__sun))
   326 +#if !(defined(__SVR4) && defined(__sun))
   325  	srq->max     = align_queue_size(attr->attr.max_wr + 1);
   327  	srq->max     = align_queue_size(attr->attr.max_wr + 1);
   326  	srq->max_gs  = attr->attr.max_sge;
   328  	srq->max_gs  = attr->attr.max_sge;
   327  	srq->counter = 0;
   329  	srq->counter = 0;
   328 @@ -324,7 +481,23 @@
   330 @@ -324,7 +483,23 @@
   329  		goto err_free;
   331  		goto err_free;
   330  
   332  
   331  	*srq->db = 0;
   333  	*srq->db = 0;
   332 +#else
   334 +#else
   333 +	/*
   335 +	/*
   347 +	attr->attr.max_wr += 1;
   349 +	attr->attr.max_wr += 1;
   348 +#endif
   350 +#endif
   349  	cmd.buf_addr = (uintptr_t) srq->buf.buf;
   351  	cmd.buf_addr = (uintptr_t) srq->buf.buf;
   350  	cmd.db_addr  = (uintptr_t) srq->db;
   352  	cmd.db_addr  = (uintptr_t) srq->db;
   351  
   353  
   352 @@ -331,19 +504,97 @@
   354 @@ -331,19 +506,97 @@
   353  	ret = ibv_cmd_create_srq(pd, &srq->ibv_srq, attr,
   355  	ret = ibv_cmd_create_srq(pd, &srq->ibv_srq, attr,
   354  				 &cmd.ibv_cmd, sizeof cmd,
   356  				 &cmd.ibv_cmd, sizeof cmd,
   355  				 &resp.ibv_resp, sizeof resp);
   357  				 &resp.ibv_resp, sizeof resp);
   356 +#if defined(__SVR4) && defined(__sun)
   358 +#if defined(__SVR4) && defined(__sun)
   357 +	if (ret) {
   359 +	if (ret) {
   445  	mlx4_free_buf(&srq->buf);
   447  	mlx4_free_buf(&srq->buf);
   446 +#endif
   448 +#endif
   447  
   449  
   448  err:
   450  err:
   449  	free(srq);
   451  	free(srq);
   450 @@ -357,7 +608,16 @@
   452 @@ -357,7 +610,16 @@
   451  {
   453  {
   452  	struct ibv_modify_srq cmd;
   454  	struct ibv_modify_srq cmd;
   453  
   455  
   454 +#if !(defined(__SVR4) && defined(__sun))
   456 +#if !(defined(__SVR4) && defined(__sun))
   455  	return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd);
   457  	return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd);
   462 +	return (ret);
   464 +	return (ret);
   463 +#endif
   465 +#endif
   464  }
   466  }
   465  
   467  
   466  int mlx4_query_srq(struct ibv_srq *srq,
   468  int mlx4_query_srq(struct ibv_srq *srq,
   467 @@ -365,7 +625,17 @@
   469 @@ -365,7 +627,17 @@
   468  {
   470  {
   469  	struct ibv_query_srq cmd;
   471  	struct ibv_query_srq cmd;
   470  
   472  
   471 +#if !(defined(__SVR4) && defined(__sun))
   473 +#if !(defined(__SVR4) && defined(__sun))
   472  	return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd);
   474  	return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd);
   480 +	return (ret);
   482 +	return (ret);
   481 +#endif
   483 +#endif
   482  }
   484  }
   483  
   485  
   484  int mlx4_destroy_srq(struct ibv_srq *ibsrq)
   486  int mlx4_destroy_srq(struct ibv_srq *ibsrq)
   485 @@ -414,7 +684,11 @@
   487 @@ -447,6 +719,10 @@
   486  		return -1;
       
   487  
       
   488  	if (attr->cap.max_inline_data) {
       
   489 +#if !(defined(__SVR4) && defined(__sun))
       
   490  		nsegs = num_inline_segs(attr->cap.max_inline_data, attr->qp_type);
       
   491 +#else
       
   492 +		nsegs = mlx4_num_inline_segs(attr->cap.max_inline_data, attr->qp_type);
       
   493 +#endif
       
   494  		size = MLX4_MAX_WQE_SIZE - nsegs * sizeof (struct mlx4_wqe_inline_seg);
       
   495  		switch (attr->qp_type) {
       
   496  		case IBV_QPT_UD:
       
   497 @@ -447,6 +721,12 @@
       
   498  	struct mlx4_qp		 *qp;
   488  	struct mlx4_qp		 *qp;
   499  	int			  ret;
   489  	int			  ret;
   500  	struct mlx4_context	 *context = to_mctx(pd->context);
   490  	struct mlx4_context	 *context = to_mctx(pd->context);
   501 +#if defined(__SVR4) && defined(__sun)
   491 +#if defined(__SVR4) && defined(__sun)
   502 +	mlnx_umap_qp_data_out_t	*mdd;
   492 +	mlnx_umap_qp_data_out_t	*mdd;
   503 +	void			*qpbuf;
   493 +	void			*qpbuf;
   504 +	int			max_send_sge;
       
   505 +	int			max_inline_data;
       
   506 +#endif
   494 +#endif
   507  
   495  
   508  
   496  
   509  	/* Sanity check QP size before proceeding */
   497  	/* Sanity check QP size before proceeding */
   510 @@ -457,6 +737,7 @@
   498 @@ -457,6 +733,7 @@
   511  	if (!qp)
   499  	if (!qp)
   512  		return NULL;
   500  		return NULL;
   513  
   501  
   514 +#if !(defined(__SVR4) && defined(__sun))
   502 +#if !(defined(__SVR4) && defined(__sun))
   515  	mlx4_calc_sq_wqe_size(&attr->cap, attr->qp_type, qp);
   503  	mlx4_calc_sq_wqe_size(&attr->cap, attr->qp_type, qp);
   516  
   504  
   517  	/*
   505  	/*
   518 @@ -466,6 +747,7 @@
   506 @@ -466,6 +743,7 @@
   519  	qp->sq_spare_wqes = (2048 >> qp->sq.wqe_shift) + 1;
   507  	qp->sq_spare_wqes = (2048 >> qp->sq.wqe_shift) + 1;
   520  	qp->sq.wqe_cnt = align_queue_size(attr->cap.max_send_wr + qp->sq_spare_wqes);
   508  	qp->sq.wqe_cnt = align_queue_size(attr->cap.max_send_wr + qp->sq_spare_wqes);
   521  	qp->rq.wqe_cnt = align_queue_size(attr->cap.max_recv_wr);
   509  	qp->rq.wqe_cnt = align_queue_size(attr->cap.max_recv_wr);
   522 +#endif
   510 +#endif
   523  
   511  
   524  	if (attr->srq || attr->qp_type == IBV_QPT_XRC)
   512  	if (attr->srq || attr->qp_type == IBV_QPT_XRC)
   525  		attr->cap.max_recv_wr = qp->rq.wqe_cnt = 0;
   513  		attr->cap.max_recv_wr = qp->rq.wqe_cnt = 0;
   526 @@ -476,6 +758,46 @@
   514 @@ -476,6 +754,22 @@
   527  			attr->cap.max_recv_wr = 1;
   515  			attr->cap.max_recv_wr = 1;
   528  	}
   516  	}
   529  
   517  
   530 +#if defined(__SVR4) && defined(__sun)
   518 +#if defined(__SVR4) && defined(__sun)
   531 +	if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) ||
   519 +	if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) ||
   532 +	    pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE)) {
   520 +	    pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE))
   533 +		goto err;
   521 +		goto err;
   534 +	}
       
   535 +
       
   536 +	/*
       
   537 +	 * We adjust the number of send SGL entries to force the kernel to
       
   538 +	 * allocate a larger WQE that will fit the inline data requested.
       
   539 +	 * The Solaris Hermon driver does not look at inline data size when
       
   540 +	 * calculating the send WQE size, so this allows us to get closer
       
   541 +	 * to what the user has requested.
       
   542 +	 */
       
   543 +	max_send_sge = align(attr->cap.max_inline_data +
       
   544 +			mlx4_num_inline_segs(attr->cap.max_inline_data,
       
   545 +			attr->qp_type) * sizeof (struct mlx4_wqe_inline_seg),
       
   546 +			sizeof( struct mlx4_wqe_data_seg)) /
       
   547 +	                          sizeof(struct mlx4_wqe_data_seg);
       
   548 +
       
   549 +
       
   550 +	if (max_send_sge > attr->cap.max_send_sge) 
       
   551 +		attr->cap.max_send_sge = max_send_sge;
       
   552 +
       
   553 +	if (attr->cap.max_send_sge > context->max_sge) {
       
   554 +		free(qp);
       
   555 +		return (NULL);
       
   556 +	};
       
   557 +
       
   558 +
   522 +
   559 +	/*
   523 +	/*
   560 +	 * Solaris QP work queue memory is supplied by the kernel, so
   524 +	 * Solaris QP work queue memory is supplied by the kernel, so
   561 +	 * we will update this after creation.
   525 +	 * we will update this after creation.
   562 +	 */
   526 +	 */
   568 +	memset(&cmd, 0, sizeof(cmd));
   532 +	memset(&cmd, 0, sizeof(cmd));
   569 +#else
   533 +#else
   570  	if (mlx4_alloc_qp_buf(pd, &attr->cap, attr->qp_type, qp))
   534  	if (mlx4_alloc_qp_buf(pd, &attr->cap, attr->qp_type, qp))
   571  		goto err;
   535  		goto err;
   572  
   536  
   573 @@ -505,11 +827,120 @@
   537 @@ -505,17 +799,84 @@
   574  		; /* nothing */
   538  		; /* nothing */
   575  	cmd.sq_no_prefetch = 0;	/* OK for ABI 2: just a reserved field */
   539  	cmd.sq_no_prefetch = 0;	/* OK for ABI 2: just a reserved field */
   576  	memset(cmd.reserved, 0, sizeof cmd.reserved);
   540  	memset(cmd.reserved, 0, sizeof cmd.reserved);
   577 +#endif
   541 +#endif
   578  
   542  
   579  	pthread_mutex_lock(&to_mctx(pd->context)->qp_table_mutex);
   543  	pthread_mutex_lock(&to_mctx(pd->context)->qp_table_mutex);
   580  
   544  
   581  	ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd,
   545  	ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd,
   582  				&resp, sizeof resp);
   546  				&resp, sizeof resp);
   583 +
   547 +#if defined(__SVR4) && defined(__sun)
   584 +#if defined(__SVR4) && defined(__sun)
   548  	if (ret)
   585 +	if (ret) {
       
   586 +		goto err_free;
   549 +		goto err_free;
   587 +	}
       
   588 +
   550 +
   589 +        /*
   551 +        /*
   590 +         * The kernel driver passes back mmap information for mapping the
   552 +         * The kernel driver passes back mmap information for mapping the
   591 +         * QP work queue memory it allocated back into user space.
   553 +         * QP work queue memory it allocated back into user space.
   592 +         */
   554 +         */
   597 +		goto err_destroy;
   559 +		goto err_destroy;
   598 +	}
   560 +	}
   599 +	qpbuf = mmap64((void *)0, mdd->mqp_maplen, (PROT_READ | PROT_WRITE),
   561 +	qpbuf = mmap64((void *)0, mdd->mqp_maplen, (PROT_READ | PROT_WRITE),
   600 +	                MAP_SHARED, pd->context->mmap_fd, mdd->mqp_mapoffset);
   562 +	                MAP_SHARED, pd->context->mmap_fd, mdd->mqp_mapoffset);
   601 +
   563 +
   602 +	if (qpbuf == MAP_FAILED) {
   564 +	if (qpbuf == MAP_FAILED)
   603 +		goto err_destroy;
   565 +		goto err_destroy;
   604 +	}
       
   605 +
   566 +
   606 +	/*
   567 +	/*
   607 +	 * Need to set qp->buf here in case alloc_db fails then
   568 +	 * Need to set qp->buf here in case alloc_db fails then
   608 +	 * we'll call mlx4_free_buf() to umap.
   569 +	 * we'll call mlx4_free_buf() to umap.
   609 +	 */
   570 +	 */
   613 +	if (!attr->srq && attr->qp_type != IBV_QPT_XRC) {
   574 +	if (!attr->srq && attr->qp_type != IBV_QPT_XRC) {
   614 +		qp->db = mlx4_alloc_db(to_mctx(pd->context),
   575 +		qp->db = mlx4_alloc_db(to_mctx(pd->context),
   615 +		                       mdd->mqp_rdbr_mapoffset,
   576 +		                       mdd->mqp_rdbr_mapoffset,
   616 +		                       mdd->mqp_rdbr_maplen,
   577 +		                       mdd->mqp_rdbr_maplen,
   617 +		                       mdd->mqp_rdbr_offset);
   578 +		                       mdd->mqp_rdbr_offset);
   618 +		if (qp->db == NULL) {
   579 +		if (qp->db == NULL)
   619 +			goto err_buf;
   580 +			goto err_buf;
   620 +		}
   581 +
   621 +		*qp->db = 0;
   582 +		*qp->db = 0;
   622 +	}
   583 +	}
   623 +
       
   624 +	/*
       
   625 +	 * Calculate the official maximum inline data size, this is not done
       
   626 +	 * by the kernel driver, so we do it here and update the qp struct.
       
   627 +	 */
       
   628 +	max_inline_data =
       
   629 +			mdd->mqp_sq_wqesz - sizeof(struct mlx4_wqe_inline_seg);
       
   630 +	max_inline_data -= sizeof(struct mlx4_wqe_ctrl_seg);
       
   631 +
       
   632 +	switch (attr->qp_type) {
       
   633 +	case IBV_QPT_UD:
       
   634 +		max_inline_data -= sizeof(struct mlx4_wqe_datagram_seg);
       
   635 +		break;
       
   636 +
       
   637 +	case IBV_QPT_UC:
       
   638 +		max_inline_data -= sizeof(struct mlx4_wqe_raddr_seg);
       
   639 +		break;
       
   640 +
       
   641 +	case IBV_QPT_RC:
       
   642 +		max_inline_data -= sizeof(struct mlx4_wqe_raddr_seg);
       
   643 +		if (max_inline_data > (sizeof(struct mlx4_wqe_atomic_seg) +
       
   644 +		                       sizeof(struct mlx4_wqe_raddr_seg) +
       
   645 +		                       sizeof(struct mlx4_wqe_data_seg))) {
       
   646 +			max_inline_data -= sizeof(struct mlx4_wqe_atomic_seg) +
       
   647 +		                           sizeof(struct mlx4_wqe_raddr_seg) +
       
   648 +		                           sizeof(struct mlx4_wqe_data_seg);
       
   649 +		} else {
       
   650 +			max_inline_data = 0;
       
   651 +		}
       
   652 +		break;
       
   653 +
       
   654 +	default:
       
   655 +		break;
       
   656 +	}
       
   657 +
       
   658 +	attr->cap.max_inline_data = max_inline_data;
       
   659 +
   584 +
   660 +	/*
   585 +	/*
   661 +	 * Retrieve sendqueue actual size, and the number of headroom WQEs
   586 +	 * Retrieve sendqueue actual size, and the number of headroom WQEs
   662 +	 * that were required based on kernel setup of prefetch or not for
   587 +	 * that were required based on kernel setup of prefetch or not for
   663 +	 * send queue.
   588 +	 * send queue.
   664 +	 * 	Note: mqp_sq_numwqe includes the head room wqes.
   589 +	 * 	Note: mqp_sq_numwqe includes the head room wqes. The private
   665 +	 *	      The private wqe.cnt also includes headroom wqes,
   590 +	 *	      wqe.cnt also includes headroom wqes, the verbs count
   666 +	 *	      the verbs count should reflect the wqe count that
   591 +	 *	      should reflect the wqe count that is usable.
   667 +	 *	      is usable.
       
   668 +	 */
   592 +	 */
   669 +	qp->sq_spare_wqes = mdd->mqp_sq_headroomwqes;
   593 +	qp->sq_spare_wqes = mdd->mqp_sq_headroomwqes;
   670 +	qp->sq.wqe_cnt    = mdd->mqp_sq_numwqe;
   594 +	qp->sq.wqe_cnt    = mdd->mqp_sq_numwqe;
   671 +
   595 +
   672 +	if (attr->srq) {
   596 +	if (attr->srq)
   673 +		qp->rq.wqe_cnt  = 0;
   597 +		qp->rq.wqe_cnt  = 0;
   674 +	} else {
   598 +	else
   675 +		qp->rq.wqe_cnt  = mdd->mqp_rq_numwqe;
   599 +		qp->rq.wqe_cnt  = mdd->mqp_rq_numwqe;
   676 +	}
       
   677 +
   600 +
   678 +	if (mlx4_set_qp_buf(pd, qp, qpbuf, mdd->mqp_maplen,
   601 +	if (mlx4_set_qp_buf(pd, qp, qpbuf, mdd->mqp_maplen,
   679 +	                    mdd->mqp_rq_wqesz, mdd->mqp_rq_off,
   602 +	                    mdd->mqp_rq_wqesz, mdd->mqp_rq_off,
   680 +	                    mdd->mqp_sq_wqesz, mdd->mqp_sq_off)) {
   603 +	                    mdd->mqp_sq_wqesz, mdd->mqp_sq_off))
   681 +		goto err_rq_db;
   604  		goto err_rq_db;
   682 +	}
   605  
   683 +
       
   684 +	mlx4_init_qp_indices(qp);
   606 +	mlx4_init_qp_indices(qp);
   685 +
   607 +
   686 +	ret = mlx4_store_qp(to_mctx(pd->context), qp->ibv_qp.qp_num, qp);
       
   687 +	if (ret) {
       
   688 +		goto err_rq_db;
       
   689 +	}
       
   690 +#else
       
   691  	if (ret)
       
   692  		goto err_rq_db;
       
   693  
       
   694 @@ -516,6 +947,7 @@
       
   695  	ret = mlx4_store_qp(to_mctx(pd->context), qp->ibv_qp.qp_num, qp);
   608  	ret = mlx4_store_qp(to_mctx(pd->context), qp->ibv_qp.qp_num, qp);
   696  	if (ret)
   609  	if (ret)
       
   610 +		goto err_rq_db;
       
   611 +#else
       
   612 +	if (ret)
       
   613 +		goto err_rq_db;
       
   614 +
       
   615 +	ret = mlx4_store_qp(to_mctx(pd->context), qp->ibv_qp.qp_num, qp);
       
   616 +	if (ret)
   697  		goto err_destroy;
   617  		goto err_destroy;
   698 +#endif
   618 +#endif
   699  	pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
   619  	pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
   700  
   620  
   701  	qp->rq.wqe_cnt = attr->cap.max_recv_wr;
   621  	qp->rq.wqe_cnt = attr->cap.max_recv_wr;
   702 @@ -536,9 +968,42 @@
   622 @@ -536,9 +897,38 @@
   703  
   623  
   704  	return &qp->ibv_qp;
   624  	return &qp->ibv_qp;
   705  
   625  
   706 +#if defined(__SVR4) && defined(__sun)
   626 +#if defined(__SVR4) && defined(__sun)
   707 +err_rq_db:
   627 +err_rq_db:
   708 +	if (!attr->srq && attr->qp_type != IBV_QPT_XRC) {
   628 +	if (!attr->srq && attr->qp_type != IBV_QPT_XRC)
   709 +		mlx4_free_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ, qp->db);
   629 +		mlx4_free_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ, qp->db);
   710 +	}
       
   711 +
       
   712 +err_buf:
   630 +err_buf:
   713 +	mlx4_free_buf(&qp->buf);
   631 +	mlx4_free_buf(&qp->buf);
   714 +
   632 +
   715  err_destroy:
   633  err_destroy:
   716 +	/*
   634 +	/*
   721 +	 */
   639 +	 */
   722 +	pthread_mutex_init(&(qp->ibv_qp.mutex), NULL);
   640 +	pthread_mutex_init(&(qp->ibv_qp.mutex), NULL);
   723 +	pthread_cond_init(&(qp->ibv_qp.cond), NULL);
   641 +	pthread_cond_init(&(qp->ibv_qp.cond), NULL);
   724 +	qp->ibv_qp.events_completed = 0;
   642 +	qp->ibv_qp.events_completed = 0;
   725  	ibv_cmd_destroy_qp(&qp->ibv_qp);
   643  	ibv_cmd_destroy_qp(&qp->ibv_qp);
   726  
       
   727 +err_free:
   644 +err_free:
   728 +	pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
   645 +	pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
   729 +
   646  
   730 +	if (qp->sq.wrid)
   647 +	if (qp->sq.wrid)
   731 +		free(qp->sq.wrid);
   648 +		free(qp->sq.wrid);
   732 +
   649 +
   733 +	if (qp->rq.wrid)
   650 +	if (qp->rq.wrid)
   734 +		free(qp->rq.wrid);
   651 +		free(qp->rq.wrid);
   735 +
       
   736 +err:
   652 +err:
   737 +	free(qp);
   653 +	free(qp);
   738 +#else
   654 +#else
   739 +err_destroy:
   655 +err_destroy:
   740 +	ibv_cmd_destroy_qp(&qp->ibv_qp);
   656 +	ibv_cmd_destroy_qp(&qp->ibv_qp);
   741 +
   657 +
   742  err_rq_db:
   658  err_rq_db:
   743  	pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
   659  	pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
   744  	if (!attr->srq && attr->qp_type != IBV_QPT_XRC)
   660  	if (!attr->srq && attr->qp_type != IBV_QPT_XRC)
   745 @@ -552,6 +1017,7 @@
   661 @@ -552,6 +942,7 @@
   746  
   662  
   747  err:
   663  err:
   748  	free(qp);
   664  	free(qp);
   749 +#endif
   665 +#endif
   750  
   666  
   751  	return NULL;
   667  	return NULL;
   752  }
   668  }
   753 @@ -745,6 +1211,13 @@
   669 @@ -745,6 +1136,13 @@
   754  				    struct ibv_cq *xrc_cq,
   670  				    struct ibv_cq *xrc_cq,
   755  				    struct ibv_srq_init_attr *attr)
   671  				    struct ibv_srq_init_attr *attr)
   756  {
   672  {
   757 +#if defined(__SVR4) && defined(__sun)
   673 +#if defined(__SVR4) && defined(__sun)
   758 +	/*
   674 +	/*
   762 +	return NULL;
   678 +	return NULL;
   763 +#else
   679 +#else
   764  	struct mlx4_create_xrc_srq  cmd;
   680  	struct mlx4_create_xrc_srq  cmd;
   765  	struct mlx4_create_srq_resp resp;
   681  	struct mlx4_create_srq_resp resp;
   766  	struct mlx4_srq		   *srq;
   682  	struct mlx4_srq		   *srq;
   767 @@ -807,6 +1280,7 @@
   683 @@ -807,6 +1205,7 @@
   768  	free(srq);
   684  	free(srq);
   769  
   685  
   770  	return NULL;
   686  	return NULL;
   771 +#endif
   687 +#endif
   772  }
   688  }
   773  
   689  
   774  struct ibv_xrc_domain *mlx4_open_xrc_domain(struct ibv_context *context,
   690  struct ibv_xrc_domain *mlx4_open_xrc_domain(struct ibv_context *context,
   775 @@ -893,5 +1367,4 @@
       
   776  {
       
   777  	return ibv_cmd_unreg_xrc_rcv_qp(xrc_domain, xrc_qp_num);
       
   778  }
       
   779 -
       
   780  #endif
       
   781 diff -r -u /tmp/839450/libmlx4-1.0.1/src/qp.c libmlx4-1.0.1/src/qp.c
   691 diff -r -u /tmp/839450/libmlx4-1.0.1/src/qp.c libmlx4-1.0.1/src/qp.c
   782 --- /tmp/839450/libmlx4-1.0.1/src/qp.c	Thu Mar 10 04:48:34 2011
   692 --- /tmp/839450/libmlx4-1.0.1/src/qp.c	Thu Mar 10 04:48:34 2011
   783 +++ libmlx4-1.0.1/src/qp.c	Tue Mar 15 07:09:43 2011
   693 +++ libmlx4-1.0.1/src/qp.c	Tue Mar 15 07:09:43 2011
   784 @@ -511,7 +511,17 @@
   694 @@ -589,6 +589,58 @@
   785  	return ret;
       
   786  }
       
   787  
       
   788 +#if defined(__SVR4) && defined(__sun)
       
   789 +/*
       
   790 + * Create a non-static version that can be called externally;
       
   791 + * default file local calls to now use the name of the non-static
       
   792 + * version.
       
   793 + */
       
   794 +#define	num_inline_segs mlx4_num_inline_segs
       
   795 +int mlx4_num_inline_segs(int data, enum ibv_qp_type type)
       
   796 +#else
       
   797  int num_inline_segs(int data, enum ibv_qp_type type)
       
   798 +#endif
       
   799  {
       
   800  	/*
       
   801  	 * Inline data segments are not allowed to cross 64 byte
       
   802 @@ -589,6 +599,58 @@
       
   803  		; /* nothing */
   695  		; /* nothing */
   804  }
   696  }
   805  
   697  
   806 +#if defined(__SVR4) && defined(__sun)
   698 +#if defined(__SVR4) && defined(__sun)
   807 +int mlx4_set_qp_buf(struct ibv_pd *pd, struct mlx4_qp *qp, void *qpbuf,
   699 +int mlx4_set_qp_buf(struct ibv_pd *pd, struct mlx4_qp *qp, void *qpbuf,
   898  			struct mlx4_srq *srq);
   790  			struct mlx4_srq *srq);
   899 +#endif
   791 +#endif
   900  void mlx4_free_srq_wqe(struct mlx4_srq *srq, int ind);
   792  void mlx4_free_srq_wqe(struct mlx4_srq *srq, int ind);
   901  int mlx4_post_srq_recv(struct ibv_srq *ibsrq,
   793  int mlx4_post_srq_recv(struct ibv_srq *ibsrq,
   902  		       struct ibv_recv_wr *wr,
   794  		       struct ibv_recv_wr *wr,
   903 @@ -399,6 +413,9 @@
   795 @@ -415,8 +429,14 @@
   904  		       struct mlx4_srq *srq);
       
   905  void mlx4_clear_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn);
       
   906  
       
   907 +#if defined(__SVR4) && defined(__sun)
       
   908 +int mlx4_num_inline_segs(int data, enum ibv_qp_type type);
       
   909 +#endif
       
   910  struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
       
   911  int mlx4_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
       
   912  		   int attr_mask,
       
   913 @@ -415,8 +432,14 @@
       
   914  void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
   796  void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
   915  			   struct mlx4_qp *qp);
   797  			   struct mlx4_qp *qp);
   916  int num_inline_segs(int data, enum ibv_qp_type type);
   798  int num_inline_segs(int data, enum ibv_qp_type type);
   917 +#if defined(__SVR4) && defined(__sun)
   799 +#if defined(__SVR4) && defined(__sun)
   918 +int mlx4_set_qp_buf(struct ibv_pd *pd, struct mlx4_qp *qp,
   800 +int mlx4_set_qp_buf(struct ibv_pd *pd, struct mlx4_qp *qp,
  1174 +	uint32_t                        temp_qp_num;
  1056 +	uint32_t                        temp_qp_num;
  1175 +#endif
  1057 +#endif
  1176  
  1058  
  1177  	context = calloc(1, sizeof *context);
  1059  	context = calloc(1, sizeof *context);
  1178  	if (!context)
  1060  	if (!context)
  1179 @@ -150,11 +155,32 @@
  1061 @@ -150,11 +155,30 @@
  1180  		return NULL;
  1062  		return NULL;
  1181  
  1063  
  1182  	context->ibv_ctx.cmd_fd = cmd_fd;
  1064  	context->ibv_ctx.cmd_fd = cmd_fd;
  1183 +#if defined(__SVR4) && defined(__sun)
  1065 +#if defined(__SVR4) && defined(__sun)
  1184 +	context->ibv_ctx.device = ibdev;
  1066 +	context->ibv_ctx.device = ibdev;
  1191 +#if defined(__SVR4) && defined(__sun)
  1073 +#if defined(__SVR4) && defined(__sun)
  1192 +	/* 
  1074 +	/* 
  1193 +	 * OFED expects power of two, round up here to make user table
  1075 +	 * OFED expects power of two, round up here to make user table
  1194 +	 * large enough.
  1076 +	 * large enough.
  1195 +	 */
  1077 +	 */
  1196 +	for (temp_qp_num = 1; temp_qp_num < resp.qp_tab_size; temp_qp_num <<= 1) {
  1078 +	for (temp_qp_num = 1; temp_qp_num < resp.qp_tab_size; temp_qp_num <<= 1)
  1197 +		;
  1079 +		;
  1198 +	}
       
  1199 +
       
  1200 +	resp.qp_tab_size = temp_qp_num;
  1080 +	resp.qp_tab_size = temp_qp_num;
  1201 +
  1081 +
  1202 +	/*
  1082 +	/*
  1203 +	 * NOTE: In Solaris this value is not returned in the channel interface
  1083 +	 * NOTE: In Solaris this value is not returned in the channel interface
  1204 +	 * opaque data and is assumed to be 2*256 by the dapl code.  We have
  1084 +	 * opaque data and is assumed to be 2*256 by the dapl code.  We have
  1207 +	resp.bf_reg_size = 512;
  1087 +	resp.bf_reg_size = 512;
  1208 +#endif
  1088 +#endif
  1209  	context->num_qps	= resp.qp_tab_size;
  1089  	context->num_qps	= resp.qp_tab_size;
  1210  	context->qp_table_shift = ffs(context->num_qps) - 1 - MLX4_QP_TABLE_BITS;
  1090  	context->qp_table_shift = ffs(context->num_qps) - 1 - MLX4_QP_TABLE_BITS;
  1211  	context->qp_table_mask	= (1 << context->qp_table_shift) - 1;
  1091  	context->qp_table_mask	= (1 << context->qp_table_shift) - 1;
  1212 @@ -172,20 +198,44 @@
  1092 @@ -172,20 +196,44 @@
  1213  	for (i = 0; i < MLX4_XRC_SRQ_TABLE_SIZE; ++i)
  1093  	for (i = 0; i < MLX4_XRC_SRQ_TABLE_SIZE; ++i)
  1214  		context->xrc_srq_table[i].refcnt = 0;
  1094  		context->xrc_srq_table[i].refcnt = 0;
  1215  
  1095  
  1216 +#if defined(__SVR4) && defined(__sun)
  1096 +#if defined(__SVR4) && defined(__sun)
  1217 +	context->db_page_list = NULL;
  1097 +	context->db_page_list = NULL;
  1252  					to_mdev(ibdev)->page_size);
  1132  					to_mdev(ibdev)->page_size);
  1253 +#endif
  1133 +#endif
  1254  		if (context->bf_page == MAP_FAILED) {
  1134  		if (context->bf_page == MAP_FAILED) {
  1255  			fprintf(stderr, PFX "Warning: BlueFlame available, "
  1135  			fprintf(stderr, PFX "Warning: BlueFlame available, "
  1256  				"but failed to mmap() BlueFlame page.\n");
  1136  				"but failed to mmap() BlueFlame page.\n");
  1257 @@ -214,6 +264,7 @@
  1137 @@ -214,6 +262,7 @@
  1258  	context->max_qp_wr = dev_attrs.max_qp_wr;
  1138  	context->max_qp_wr = dev_attrs.max_qp_wr;
  1259  	context->max_sge = dev_attrs.max_sge;
  1139  	context->max_sge = dev_attrs.max_sge;
  1260  	context->max_cqe = dev_attrs.max_cqe;
  1140  	context->max_cqe = dev_attrs.max_cqe;
  1261 +#ifdef HAVE_IBV_XRC_OPS
  1141 +#ifdef HAVE_IBV_XRC_OPS
  1262  	if (!(dev_attrs.device_cap_flags & IBV_DEVICE_XRC)) {
  1142  	if (!(dev_attrs.device_cap_flags & IBV_DEVICE_XRC)) {
  1263  		fprintf(stderr, PFX "There is a mismatch between "
  1143  		fprintf(stderr, PFX "There is a mismatch between "
  1264  		        "the kernel and the userspace libraries: "
  1144  		        "the kernel and the userspace libraries: "
  1265 @@ -220,6 +271,7 @@
  1145 @@ -220,6 +269,7 @@
  1266  			"Kernel does not support XRC. Exiting.\n");
  1146  			"Kernel does not support XRC. Exiting.\n");
  1267  		goto query_free;
  1147  		goto query_free;
  1268  	}
  1148  	}
  1269 +#endif
  1149 +#endif
  1270  
  1150  
  1271  	return &context->ibv_ctx;
  1151  	return &context->ibv_ctx;
  1272  
  1152  
  1273 @@ -227,7 +279,6 @@
  1153 @@ -240,6 +290,7 @@
  1274  	munmap(context->uar, to_mdev(ibdev)->page_size);
       
  1275  	if (context->bf_page)
       
  1276  		munmap(context->bf_page, to_mdev(ibdev)->page_size);
       
  1277 -
       
  1278  err_free:
       
  1279  	free(context);
       
  1280  	return NULL;
       
  1281 @@ -240,6 +291,7 @@
       
  1282  	munmap(context->uar, to_mdev(ibctx->device)->page_size);
  1154  	munmap(context->uar, to_mdev(ibctx->device)->page_size);
  1283  	if (context->bf_page)
  1155  	if (context->bf_page)
  1284  		munmap(context->bf_page, to_mdev(ibctx->device)->page_size);
  1156  		munmap(context->bf_page, to_mdev(ibctx->device)->page_size);
  1285 +
  1157 +
  1286  	free(context);
  1158  	free(context);
  1318 @@ -6,7 +6,7 @@
  1190 @@ -6,7 +6,7 @@
  1319  Group: System Environment/Libraries
  1191  Group: System Environment/Libraries
  1320  License: GPLv2 or BSD
  1192  License: GPLv2 or BSD
  1321  Url: http://openfabrics.org/
  1193  Url: http://openfabrics.org/
  1322 -Source: http://openfabrics.org/downloads/libmlx4/libmlx4-1.0.1.tar.gz
  1194 -Source: http://openfabrics.org/downloads/libmlx4/libmlx4-1.0.1.tar.gz
  1323 +Source: http://openfabrics.org/downloads/mlx4/libmlx4-1.0.1.tar.gz
  1195 +Source: http://openfabrics.org/downloads/libmlx4-1.0.1.tar.gz
  1324  BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
  1196  BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
  1325  
  1197  
  1326  BuildRequires: libibverbs-devel >= 1.1-0.1.rc2
  1198  BuildRequires: libibverbs-devel >= 1.1-0.1.rc2
  1327 diff -r -u /tmp/839450/libmlx4-1.0.1/configure libmlx4-1.0.1/configure
  1199 diff -r -u /tmp/839450/libmlx4-1.0.1/configure libmlx4-1.0.1/configure
  1328 --- /tmp/839450/libmlx4-1.0.1/configure	Thu Mar 10 04:48:41 2011
  1200 --- /tmp/839450/libmlx4-1.0.1/configure	Thu Mar 10 04:48:41 2011
  1329 +++ libmlx4-1.0.1/configure	Tue Mar 15 07:35:49 2011
  1201 +++ libmlx4-1.0.1/configure	Tue Mar 15 07:35:49 2011
       
  1202 @@ -3899,13 +3899,13 @@
       
  1203    CFLAGS=$ac_save_CFLAGS
       
  1204  elif test $ac_cv_prog_cc_g = yes; then
       
  1205    if test "$GCC" = yes; then
       
  1206 -    CFLAGS="-g -O2"
       
  1207 +    CFLAGS="-g -O3"
       
  1208    else
       
  1209      CFLAGS="-g"
       
  1210    fi
       
  1211  else
       
  1212    if test "$GCC" = yes; then
       
  1213 -    CFLAGS="-O2"
       
  1214 +    CFLAGS="-O3"
       
  1215    else
       
  1216      CFLAGS=
       
  1217    fi
  1330 @@ -8890,6 +8890,7 @@
  1218 @@ -8890,6 +8890,7 @@
  1331  	;;
  1219  	;;
  1332        esac
  1220        esac
  1333        link_all_deplibs=yes
  1221        link_all_deplibs=yes
  1334 +	hardcode_libdir_flag_spec=
  1222 +	hardcode_libdir_flag_spec=
  1335        ;;
  1223        ;;
  1336  
  1224  
  1337      sunos4*)
  1225      sunos4*)
  1338 @@ -11616,6 +11617,14 @@
  1226 @@ -11113,13 +11114,13 @@
  1339  # This bug is HP SR number 8606223364.
  1227    CFLAGS=$ac_save_CFLAGS
  1340  { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
  1228  elif test $ac_cv_prog_cc_g = yes; then
  1341  $as_echo_n "checking size of long... " >&6; }
  1229    if test "$GCC" = yes; then
  1342 +
  1230 -    CFLAGS="-g -O2"
  1343 +echo $CFLAGS | grep 64 > /dev/null
  1231 +    CFLAGS="-g -O3"
  1344 +if [ $? -eq 0 ]; then
  1232    else
  1345 +	ac_cv_sizeof_long=8
  1233      CFLAGS="-g"
  1346 +else
  1234    fi
  1347 +	ac_cv_sizeof_long=4
       
  1348 +fi
       
  1349 +
       
  1350  if test "${ac_cv_sizeof_long+set}" = set; then :
       
  1351    $as_echo_n "(cached) " >&6
       
  1352  else
  1235  else
  1353 @@ -11654,11 +11663,11 @@
  1236    if test "$GCC" = yes; then
       
  1237 -    CFLAGS="-O2"
       
  1238 +    CFLAGS="-O3"
       
  1239    else
       
  1240      CFLAGS=
       
  1241    fi
       
  1242 @@ -11654,11 +11655,11 @@
  1354  
  1243  
  1355  ac_fn_c_check_member "$LINENO" "struct ibv_more_ops" "create_xrc_srq" "ac_cv_member_struct_ibv_more_ops_create_xrc_srq" "#include <infiniband/verbs.h>
  1244  ac_fn_c_check_member "$LINENO" "struct ibv_more_ops" "create_xrc_srq" "ac_cv_member_struct_ibv_more_ops_create_xrc_srq" "#include <infiniband/verbs.h>
  1356  "
  1245  "
  1357 -if test "x$ac_cv_member_struct_ibv_more_ops_create_xrc_srq" = x""yes; then :
  1246 -if test "x$ac_cv_member_struct_ibv_more_ops_create_xrc_srq" = x""yes; then :
  1358 +#if test "x$ac_cv_member_struct_ibv_more_ops_create_xrc_srq" = x""yes; then :
  1247 +#if test "x$ac_cv_member_struct_ibv_more_ops_create_xrc_srq" = x""yes; then :