Print this page
5255 uts shouldn't open-code ISP2


  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 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * tavor_qpmod.c
  29  *    Tavor Queue Pair Modify Routines
  30  *
  31  *    This contains all the routines necessary to implement the Tavor
  32  *    ModifyQP() verb.  This includes all the code for legal transitions to
  33  *    and from Reset, Init, RTR, RTS, SQD, SQErr, 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/tavor/tavor.h>
  44 #include <sys/ib/ib_pkt_hdrs.h>
  45 
  46 static int tavor_qp_reset2init(tavor_state_t *state, tavor_qphdl_t qp,
  47     ibt_qp_info_t *info_p);
  48 static int tavor_qp_init2init(tavor_state_t *state, tavor_qphdl_t qp,
  49     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
  50 static int tavor_qp_init2rtr(tavor_state_t *state, tavor_qphdl_t qp,
  51     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
  52 static int tavor_qp_rtr2rts(tavor_state_t *state, tavor_qphdl_t qp,
  53     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
  54 static int tavor_qp_rts2rts(tavor_state_t *state, tavor_qphdl_t qp,
  55     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);


3421 {
3422         uint_t  rdma_ra_in;
3423 
3424         rdma_ra_in = rc->rc_rdma_ra_in;
3425 
3426         /*
3427          * Check if number of responder resources is too large.  Return an
3428          * error if it is
3429          */
3430         if (rdma_ra_in > state->ts_cfg_profile->cp_hca_max_rdma_in_qp) {
3431                 return (IBT_INVALID_PARAM);
3432         }
3433 
3434         /*
3435          * If the number of responder resources is too small, round it up.
3436          * Then find the next highest power-of-2
3437          */
3438         if (rdma_ra_in == 0) {
3439                 rdma_ra_in = 1;
3440         }
3441         if ((rdma_ra_in & (rdma_ra_in - 1)) == 0) {
3442                 *rra_max = highbit(rdma_ra_in) - 1;
3443         } else {
3444                 *rra_max = highbit(rdma_ra_in);
3445         }
3446         return (DDI_SUCCESS);
3447 }
3448 
3449 
3450 /*
3451  * tavor_qp_validate_init_depth()
3452  *    Context: Can be called from interrupt or base context.
3453  */
3454 static int
3455 tavor_qp_validate_init_depth(tavor_state_t *state, ibt_qp_rc_attr_t *rc,
3456     uint_t *sra_max)
3457 {
3458         uint_t  rdma_ra_out;
3459 
3460         rdma_ra_out = rc->rc_rdma_ra_out;
3461 
3462         /*
3463          * Check if requested initiator depth is too large.  Return an error
3464          * if it is
3465          */
3466         if (rdma_ra_out > state->ts_cfg_profile->cp_hca_max_rdma_out_qp) {
3467                 return (IBT_INVALID_PARAM);
3468         }
3469 
3470         /*
3471          * If the requested initiator depth is too small, round it up.
3472          * Then find the next highest power-of-2
3473          */
3474         if (rdma_ra_out == 0) {
3475                 rdma_ra_out = 1;
3476         }
3477         if ((rdma_ra_out & (rdma_ra_out - 1)) == 0) {
3478                 *sra_max = highbit(rdma_ra_out) - 1;
3479         } else {
3480                 *sra_max = highbit(rdma_ra_out);
3481         }
3482         return (DDI_SUCCESS);
3483 }
3484 
3485 
3486 /*
3487  * tavor_qp_validate_mtu()
3488  *    Context: Can be called from interrupt or base context.
3489  */
3490 static int
3491 tavor_qp_validate_mtu(tavor_state_t *state, uint_t mtu)
3492 {
3493         /*
3494          * Check for invalid MTU values (i.e. zero or any value larger than
3495          * the HCA's port maximum).
3496          */
3497         if ((mtu == 0) || (mtu > state->ts_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 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * tavor_qpmod.c
  29  *    Tavor Queue Pair Modify Routines
  30  *
  31  *    This contains all the routines necessary to implement the Tavor
  32  *    ModifyQP() verb.  This includes all the code for legal transitions to
  33  *    and from Reset, Init, RTR, RTS, SQD, SQErr, 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/tavor/tavor.h>
  45 #include <sys/ib/ib_pkt_hdrs.h>
  46 
  47 static int tavor_qp_reset2init(tavor_state_t *state, tavor_qphdl_t qp,
  48     ibt_qp_info_t *info_p);
  49 static int tavor_qp_init2init(tavor_state_t *state, tavor_qphdl_t qp,
  50     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
  51 static int tavor_qp_init2rtr(tavor_state_t *state, tavor_qphdl_t qp,
  52     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
  53 static int tavor_qp_rtr2rts(tavor_state_t *state, tavor_qphdl_t qp,
  54     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
  55 static int tavor_qp_rts2rts(tavor_state_t *state, tavor_qphdl_t qp,
  56     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);


3422 {
3423         uint_t  rdma_ra_in;
3424 
3425         rdma_ra_in = rc->rc_rdma_ra_in;
3426 
3427         /*
3428          * Check if number of responder resources is too large.  Return an
3429          * error if it is
3430          */
3431         if (rdma_ra_in > state->ts_cfg_profile->cp_hca_max_rdma_in_qp) {
3432                 return (IBT_INVALID_PARAM);
3433         }
3434 
3435         /*
3436          * If the number of responder resources is too small, round it up.
3437          * Then find the next highest power-of-2
3438          */
3439         if (rdma_ra_in == 0) {
3440                 rdma_ra_in = 1;
3441         }
3442         if (ISP2(rdma_ra_in)) {
3443                 *rra_max = highbit(rdma_ra_in) - 1;
3444         } else {
3445                 *rra_max = highbit(rdma_ra_in);
3446         }
3447         return (DDI_SUCCESS);
3448 }
3449 
3450 
3451 /*
3452  * tavor_qp_validate_init_depth()
3453  *    Context: Can be called from interrupt or base context.
3454  */
3455 static int
3456 tavor_qp_validate_init_depth(tavor_state_t *state, ibt_qp_rc_attr_t *rc,
3457     uint_t *sra_max)
3458 {
3459         uint_t  rdma_ra_out;
3460 
3461         rdma_ra_out = rc->rc_rdma_ra_out;
3462 
3463         /*
3464          * Check if requested initiator depth is too large.  Return an error
3465          * if it is
3466          */
3467         if (rdma_ra_out > state->ts_cfg_profile->cp_hca_max_rdma_out_qp) {
3468                 return (IBT_INVALID_PARAM);
3469         }
3470 
3471         /*
3472          * If the requested initiator depth is too small, round it up.
3473          * Then find the next highest power-of-2
3474          */
3475         if (rdma_ra_out == 0) {
3476                 rdma_ra_out = 1;
3477         }
3478         if (ISP2(rdma_ra_out)) {
3479                 *sra_max = highbit(rdma_ra_out) - 1;
3480         } else {
3481                 *sra_max = highbit(rdma_ra_out);
3482         }
3483         return (DDI_SUCCESS);
3484 }
3485 
3486 
3487 /*
3488  * tavor_qp_validate_mtu()
3489  *    Context: Can be called from interrupt or base context.
3490  */
3491 static int
3492 tavor_qp_validate_mtu(tavor_state_t *state, uint_t mtu)
3493 {
3494         /*
3495          * Check for invalid MTU values (i.e. zero or any value larger than
3496          * the HCA's port maximum).
3497          */
3498         if ((mtu == 0) || (mtu > state->ts_cfg_profile->cp_max_mtu)) {