16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /*
27 * hermon_qpmod.c
28 * Hermon Queue Pair Modify Routines
29 *
30 * This contains all the routines necessary to implement the
31 * ModifyQP() verb. This includes all the code for legal
32 * transitions to and from Reset, Init, RTR, RTS, SQD, SQErr,
33 * and Error.
34 */
35
36 #include <sys/types.h>
37 #include <sys/conf.h>
38 #include <sys/ddi.h>
39 #include <sys/sunddi.h>
40 #include <sys/modctl.h>
41 #include <sys/bitmap.h>
42
43 #include <sys/ib/adapters/hermon/hermon.h>
44 #include <sys/ib/ib_pkt_hdrs.h>
45
46 static int hermon_qp_reset2init(hermon_state_t *state, hermon_qphdl_t qp,
47 ibt_qp_info_t *info_p);
48 static int hermon_qp_init2init(hermon_state_t *state, hermon_qphdl_t qp,
49 ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
50 static int hermon_qp_init2rtr(hermon_state_t *state, hermon_qphdl_t qp,
51 ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
52 static int hermon_qp_rtr2rts(hermon_state_t *state, hermon_qphdl_t qp,
53 ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
54 static int hermon_qp_rts2rts(hermon_state_t *state, hermon_qphdl_t qp,
55 ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
3358 {
3359 uint_t rdma_ra_in;
3360
3361 rdma_ra_in = rc->rc_rdma_ra_in;
3362
3363 /*
3364 * Check if number of responder resources is too large. Return an
3365 * error if it is
3366 */
3367 if (rdma_ra_in > state->hs_cfg_profile->cp_hca_max_rdma_in_qp) {
3368 return (IBT_INVALID_PARAM);
3369 }
3370
3371 /*
3372 * If the number of responder resources is too small, round it up.
3373 * Then find the next highest power-of-2
3374 */
3375 if (rdma_ra_in == 0) {
3376 rdma_ra_in = 1;
3377 }
3378 if ((rdma_ra_in & (rdma_ra_in - 1)) == 0) {
3379 *rra_max = highbit(rdma_ra_in) - 1;
3380 } else {
3381 *rra_max = highbit(rdma_ra_in);
3382 }
3383 return (DDI_SUCCESS);
3384 }
3385
3386
3387 /*
3388 * hermon_qp_validate_init_depth()
3389 * Context: Can be called from interrupt or base context.
3390 */
3391 static int
3392 hermon_qp_validate_init_depth(hermon_state_t *state, ibt_qp_rc_attr_t *rc,
3393 uint_t *sra_max)
3394 {
3395 uint_t rdma_ra_out;
3396
3397 rdma_ra_out = rc->rc_rdma_ra_out;
3398
3399 /*
3400 * Check if requested initiator depth is too large. Return an error
3401 * if it is
3402 */
3403 if (rdma_ra_out > state->hs_cfg_profile->cp_hca_max_rdma_out_qp) {
3404 return (IBT_INVALID_PARAM);
3405 }
3406
3407 /*
3408 * If the requested initiator depth is too small, round it up.
3409 * Then find the next highest power-of-2
3410 */
3411 if (rdma_ra_out == 0) {
3412 rdma_ra_out = 1;
3413 }
3414 if ((rdma_ra_out & (rdma_ra_out - 1)) == 0) {
3415 *sra_max = highbit(rdma_ra_out) - 1;
3416 } else {
3417 *sra_max = highbit(rdma_ra_out);
3418 }
3419 return (DDI_SUCCESS);
3420 }
3421
3422
3423 /*
3424 * hermon_qp_validate_mtu()
3425 * Context: Can be called from interrupt or base context.
3426 */
3427 static int
3428 hermon_qp_validate_mtu(hermon_state_t *state, uint_t mtu)
3429 {
3430 /*
3431 * Check for invalid MTU values (i.e. zero or any value larger than
3432 * the HCA's port maximum).
3433 */
3434 if ((mtu == 0) || (mtu > state->hs_cfg_profile->cp_max_mtu)) {
|
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /*
27 * hermon_qpmod.c
28 * Hermon Queue Pair Modify Routines
29 *
30 * This contains all the routines necessary to implement the
31 * ModifyQP() verb. This includes all the code for legal
32 * transitions to and from Reset, Init, RTR, RTS, SQD, SQErr,
33 * and Error.
34 */
35
36 #include <sys/sysmacros.h>
37 #include <sys/types.h>
38 #include <sys/conf.h>
39 #include <sys/ddi.h>
40 #include <sys/sunddi.h>
41 #include <sys/modctl.h>
42 #include <sys/bitmap.h>
43
44 #include <sys/ib/adapters/hermon/hermon.h>
45 #include <sys/ib/ib_pkt_hdrs.h>
46
47 static int hermon_qp_reset2init(hermon_state_t *state, hermon_qphdl_t qp,
48 ibt_qp_info_t *info_p);
49 static int hermon_qp_init2init(hermon_state_t *state, hermon_qphdl_t qp,
50 ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
51 static int hermon_qp_init2rtr(hermon_state_t *state, hermon_qphdl_t qp,
52 ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
53 static int hermon_qp_rtr2rts(hermon_state_t *state, hermon_qphdl_t qp,
54 ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
55 static int hermon_qp_rts2rts(hermon_state_t *state, hermon_qphdl_t qp,
56 ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
3359 {
3360 uint_t rdma_ra_in;
3361
3362 rdma_ra_in = rc->rc_rdma_ra_in;
3363
3364 /*
3365 * Check if number of responder resources is too large. Return an
3366 * error if it is
3367 */
3368 if (rdma_ra_in > state->hs_cfg_profile->cp_hca_max_rdma_in_qp) {
3369 return (IBT_INVALID_PARAM);
3370 }
3371
3372 /*
3373 * If the number of responder resources is too small, round it up.
3374 * Then find the next highest power-of-2
3375 */
3376 if (rdma_ra_in == 0) {
3377 rdma_ra_in = 1;
3378 }
3379 if (ISP2(rdma_ra_in)) {
3380 *rra_max = highbit(rdma_ra_in) - 1;
3381 } else {
3382 *rra_max = highbit(rdma_ra_in);
3383 }
3384 return (DDI_SUCCESS);
3385 }
3386
3387
3388 /*
3389 * hermon_qp_validate_init_depth()
3390 * Context: Can be called from interrupt or base context.
3391 */
3392 static int
3393 hermon_qp_validate_init_depth(hermon_state_t *state, ibt_qp_rc_attr_t *rc,
3394 uint_t *sra_max)
3395 {
3396 uint_t rdma_ra_out;
3397
3398 rdma_ra_out = rc->rc_rdma_ra_out;
3399
3400 /*
3401 * Check if requested initiator depth is too large. Return an error
3402 * if it is
3403 */
3404 if (rdma_ra_out > state->hs_cfg_profile->cp_hca_max_rdma_out_qp) {
3405 return (IBT_INVALID_PARAM);
3406 }
3407
3408 /*
3409 * If the requested initiator depth is too small, round it up.
3410 * Then find the next highest power-of-2
3411 */
3412 if (rdma_ra_out == 0) {
3413 rdma_ra_out = 1;
3414 }
3415 if (ISP2(rdma_ra_out)) {
3416 *sra_max = highbit(rdma_ra_out) - 1;
3417 } else {
3418 *sra_max = highbit(rdma_ra_out);
3419 }
3420 return (DDI_SUCCESS);
3421 }
3422
3423
3424 /*
3425 * hermon_qp_validate_mtu()
3426 * Context: Can be called from interrupt or base context.
3427 */
3428 static int
3429 hermon_qp_validate_mtu(hermon_state_t *state, uint_t mtu)
3430 {
3431 /*
3432 * Check for invalid MTU values (i.e. zero or any value larger than
3433 * the HCA's port maximum).
3434 */
3435 if ((mtu == 0) || (mtu > state->hs_cfg_profile->cp_max_mtu)) {
|