/** * rvt_query_port: Passes the query port call to the driver * @ibdev: Verbs IB dev * @port_num: port number, 1 based from ib core * @props: structure to hold returned properties * * Return: 0 on success */ static int rvt_query_port(struct ib_device *ibdev, u8 port_num, struct ib_port_attr *props) { struct rvt_dev_info *rdi = ib_to_rvt(ibdev); struct rvt_ibport *rvp; int port_index = ibport_num_to_idx(ibdev, port_num); if (port_index < 0) return -EINVAL; rvp = rdi->ports[port_index]; /* props being zeroed by the caller, avoid zeroing it here */ props->sm_lid = rvp->sm_lid; props->sm_sl = rvp->sm_sl; props->port_cap_flags = rvp->port_cap_flags; props->max_msg_sz = 0x80000000; props->pkey_tbl_len = rvt_get_npkeys(rdi); props->bad_pkey_cntr = rvp->pkey_violations; props->qkey_viol_cntr = rvp->qkey_violations; props->subnet_timeout = rvp->subnet_timeout; props->init_type_reply = 0; /* Populate the remaining ib_port_attr elements */ return rdi->driver_f.query_port_state(rdi, port_num, props); }
/** * rvt_modify_port * @ibdev: Verbs IB dev * @port_num: Port number, 1 based from ib core * @port_modify_mask: How to change the port * @props: Structure to fill in * * Return: 0 on success */ static int rvt_modify_port(struct ib_device *ibdev, u8 port_num, int port_modify_mask, struct ib_port_modify *props) { struct rvt_dev_info *rdi = ib_to_rvt(ibdev); struct rvt_ibport *rvp; int ret = 0; int port_index = ibport_num_to_idx(ibdev, port_num); if (port_index < 0) return -EINVAL; rvp = rdi->ports[port_index]; if (port_modify_mask & IB_PORT_OPA_MASK_CHG) { rvp->port_cap3_flags |= props->set_port_cap_mask; rvp->port_cap3_flags &= ~props->clr_port_cap_mask; } else { rvp->port_cap_flags |= props->set_port_cap_mask; rvp->port_cap_flags &= ~props->clr_port_cap_mask; } if (props->set_port_cap_mask || props->clr_port_cap_mask) rdi->driver_f.cap_mask_chg(rdi, port_num); if (port_modify_mask & IB_PORT_SHUTDOWN) ret = rdi->driver_f.shut_down_port(rdi, port_num); if (port_modify_mask & IB_PORT_RESET_QKEY_CNTR) rvp->qkey_violations = 0; return ret; }
/** * rvt_process_mad - process an incoming MAD packet * @ibdev: the infiniband device this packet came in on * @mad_flags: MAD flags * @port_num: the port number this packet came in on, 1 based from ib core * @in_wc: the work completion entry for this packet * @in_grh: the global route header for this packet * @in_mad: the incoming MAD * @out_mad: any outgoing MAD reply * * Note that the verbs framework has already done the MAD sanity checks, * and hop count/pointer updating for IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE * MADs. * * This is called by the ib_mad module. * * Return: IB_MAD_RESULT_SUCCESS or error */ int rvt_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, const struct ib_wc *in_wc, const struct ib_grh *in_grh, const struct ib_mad_hdr *in, size_t in_mad_size, struct ib_mad_hdr *out, size_t *out_mad_size, u16 *out_mad_pkey_index) { /* * MAD processing is quite different between hfi1 and qib. Therfore this * is expected to be provided by the driver. Other drivers in the future * may chose to implement this but it should not be made into a * requirement. */ if (ibport_num_to_idx(ibdev, port_num) < 0) return -EINVAL; return IB_MAD_RESULT_FAILURE; }
/** * rvt_query_pkey - Return a pkey from the table at a given index * @ibdev: Verbs IB dev * @port_num: Port number, 1 based from ib core * @index: Index into pkey table * @pkey: returned pkey from the port pkey table * * Return: 0 on failure pkey otherwise */ static int rvt_query_pkey(struct ib_device *ibdev, u8 port_num, u16 index, u16 *pkey) { /* * Driver will be responsible for keeping rvt_dev_info.pkey_table up to * date. This function will just return that value. There is no need to * lock, if a stale value is read and sent to the user so be it there is * no way to protect against that anyway. */ struct rvt_dev_info *rdi = ib_to_rvt(ibdev); int port_index; port_index = ibport_num_to_idx(ibdev, port_num); if (port_index < 0) return -EINVAL; if (index >= rvt_get_npkeys(rdi)) return -EINVAL; *pkey = rvt_get_pkey(rdi, port_index, index); return 0; }
/** * rvt_query_gid - Return a gid from the table * @ibdev: Verbs IB dev * @port_num: Port number, 1 based from ib core * @guid_index: Index in table * @gid: Gid to return * * Return: 0 on success */ static int rvt_query_gid(struct ib_device *ibdev, u8 port_num, int guid_index, union ib_gid *gid) { struct rvt_dev_info *rdi; struct rvt_ibport *rvp; int port_index; /* * Driver is responsible for updating the guid table. Which will be used * to craft the return value. This will work similar to how query_pkey() * is being done. */ port_index = ibport_num_to_idx(ibdev, port_num); if (port_index < 0) return -EINVAL; rdi = ib_to_rvt(ibdev); rvp = rdi->ports[port_index]; gid->global.subnet_prefix = rvp->gid_prefix; return rdi->driver_f.get_guid_be(rdi, rvp, guid_index, &gid->global.interface_id); }