Lines Matching refs:afu

49 	struct afu *afu = cmd->parent;
50 struct cxlflash_cfg *cfg = afu->parent;
161 struct afu *afu = cmd->parent;
162 struct cxlflash_cfg *cfg = afu->parent;
164 struct hwq *hwq = get_hwq(afu, cmd->hwq_index);
198 struct cxlflash_cfg *cfg = hwq->afu->parent;
242 struct cxlflash_cfg *cfg = hwq->afu->parent;
299 * @afu: AFU associated with the host.
305 static int send_cmd_ioarrin(struct afu *afu, struct afu_cmd *cmd)
307 struct cxlflash_cfg *cfg = afu->parent;
309 struct hwq *hwq = get_hwq(afu, cmd->hwq_index);
343 * @afu: AFU associated with the host.
349 static int send_cmd_sq(struct afu *afu, struct afu_cmd *cmd)
351 struct cxlflash_cfg *cfg = afu->parent;
353 struct hwq *hwq = get_hwq(afu, cmd->hwq_index);
389 * @afu: AFU associated with the host.
394 static int wait_resp(struct afu *afu, struct afu_cmd *cmd)
396 struct cxlflash_cfg *cfg = afu->parent;
421 * @afu: SCSI command to send.
428 struct afu *afu)
433 if (afu->num_hwqs == 1)
436 switch (afu->hwq_mode) {
438 hwq = afu->hwq_rr_count++ % afu->num_hwqs;
445 hwq = smp_processor_id() % afu->num_hwqs;
466 struct afu *afu = cfg->afu;
469 struct hwq *hwq = get_hwq(afu, PRIMARY_HWQ);
495 cmd->parent = afu;
508 rc = afu->send_cmd(afu, cmd);
568 struct afu *afu = cfg->afu;
572 int hwq_index = cmd_to_target_hwq(host, scp, afu);
573 struct hwq *hwq = get_hwq(afu, hwq_index);
613 atomic_inc(&afu->cmds_active);
623 cmd->parent = afu;
638 rc = afu->send_cmd(afu, cmd);
639 atomic_dec(&afu->cmds_active);
664 struct afu *afu = cfg->afu;
666 if (cfg->afu) {
667 free_pages((ulong)afu, get_order(sizeof(struct afu)));
668 cfg->afu = NULL;
697 struct afu *afu = cfg->afu;
705 if (likely(afu)) {
706 while (atomic_read(&afu->cmds_active))
709 if (afu_is_irqpoll_enabled(afu)) {
710 for (i = 0; i < afu->num_hwqs; i++) {
711 hwq = get_hwq(afu, i);
717 if (likely(afu->afu_map)) {
718 cfg->ops->psa_unmap(afu->afu_map);
719 afu->afu_map = NULL;
735 struct afu *afu = cfg->afu;
739 if (!afu) {
740 dev_err(dev, "%s: returning with NULL afu\n", __func__);
744 hwq = get_hwq(afu, index);
781 struct afu *afu = cfg->afu;
786 if (!afu) {
787 dev_err(dev, "%s: returning with NULL afu\n", __func__);
791 hwq = get_hwq(afu, index);
832 for (k = cfg->afu->num_hwqs - 1; k >= 0; k--)
837 for (k = cfg->afu->num_hwqs - 1; k >= 0; k--)
855 struct afu *afu = cfg->afu;
866 if (!afu || !afu->afu_map) {
1016 cfg->afu = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
1017 get_order(sizeof(struct afu)));
1018 if (unlikely(!cfg->afu)) {
1020 __func__, get_order(sizeof(struct afu)));
1024 cfg->afu->parent = cfg;
1025 cfg->afu->desired_hwqs = CXLFLASH_DEF_HWQS;
1026 cfg->afu->afu_map = NULL;
1182 * @afu: AFU associated with the host that owns the specified FC port.
1193 static void afu_set_wwpn(struct afu *afu, int port, __be64 __iomem *fc_regs,
1196 struct cxlflash_cfg *cfg = afu->parent;
1218 * @afu: AFU associated with the host that owns the specified FC port.
1229 static void afu_link_reset(struct afu *afu, int port, __be64 __iomem *fc_regs)
1231 struct cxlflash_cfg *cfg = afu->parent;
1236 port_sel = readq_be(&afu->afu_map->global.regs.afu_port_sel);
1238 writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel);
1239 cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);
1255 writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel);
1256 cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);
1263 * @afu: AFU associated with the host.
1265 static void afu_err_intr_init(struct afu *afu)
1267 struct cxlflash_cfg *cfg = afu->parent;
1270 struct hwq *hwq = get_hwq(afu, PRIMARY_HWQ);
1281 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_mask);
1285 if (afu->internal_lun)
1287 writeq_be(reg, &afu->afu_map->global.regs.afu_ctrl);
1289 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_clear);
1291 /* note: afu can send an interrupt after this step */
1292 writeq_be(SISL_ASTATUS_MASK, &afu->afu_map->global.regs.aintr_mask);
1295 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_clear);
1301 if (afu->internal_lun)
1302 reg |= ((u64)(afu->internal_lun - 1) << SISL_FC_INTERNAL_SHIFT);
1319 for (i = 0; i < afu->num_hwqs; i++) {
1320 hwq = get_hwq(afu, i);
1340 struct cxlflash_cfg *cfg = hwq->afu->parent;
1375 struct afu *afu = hwq->afu;
1395 if (afu_is_sq_cmd_mode(afu)) {
1478 struct afu *afu = hwq->afu;
1491 if (afu_is_irqpoll_enabled(afu)) {
1546 struct afu *afu = hwq->afu;
1547 struct cxlflash_cfg *cfg = afu->parent;
1550 struct sisl_global_map __iomem *global = &afu->afu_map->global;
1714 struct afu *afu = cfg->afu;
1721 ctrl_map = &afu->afu_map->ctrls[i].ctrl;
1730 for (i = 0; i < afu->num_hwqs; i++) {
1731 hwq = get_hwq(afu, i);
1735 hwq->host_map = &afu->afu_map->hosts[hwq->ctx_hndl].host;
1736 hwq->ctrl_map = &afu->afu_map->ctrls[hwq->ctx_hndl].ctrl;
1749 struct afu *afu = cfg->afu;
1768 for (i = 0; i < afu->num_hwqs; i++) {
1769 hwq = get_hwq(afu, i);
1776 if (afu_is_sq_cmd_mode(afu)) {
1783 reg = readq_be(&afu->afu_map->global.regs.afu_config);
1788 /* checker on if dual afu */
1789 writeq_be(reg, &afu->afu_map->global.regs.afu_config);
1792 if (afu->internal_lun) {
1794 writeq_be(PORT0, &afu->afu_map->global.regs.afu_port_sel);
1798 &afu->afu_map->global.regs.afu_port_sel);
1813 afu_set_wwpn(afu, i, &fc_port_regs[0], wwpn[i]);
1820 if (afu_is_ocxl_lisn(afu)) {
1822 for (i = 0; i < afu->num_hwqs; i++) {
1823 hwq = get_hwq(afu, i);
1840 /* tables, afu cmds and read/write GSCSI cmds. */
1842 for (i = 0; i < afu->num_hwqs; i++) {
1843 hwq = get_hwq(afu, i);
1858 hwq = get_hwq(afu, PRIMARY_HWQ);
1864 afu->hb = readq_be(&afu->afu_map->global.regs.afu_hb);
1875 struct afu *afu = cfg->afu;
1884 for (i = 0; i < afu->num_hwqs; i++) {
1885 hwq = get_hwq(afu, i);
1901 if (afu_is_sq_cmd_mode(afu)) {
1911 if (afu_is_irqpoll_enabled(afu))
1912 irq_poll_init(&hwq->irqpoll, afu->irqpoll_weight,
1990 struct hwq *hwq = get_hwq(cfg->afu, index);
1995 hwq->afu = cfg->afu;
2071 struct afu *afu = cfg->afu;
2076 port_mask = readq_be(&afu->afu_map->global.regs.afu_port_sel);
2100 struct afu *afu = cfg->afu;
2107 mutex_init(&afu->sync_active);
2108 afu->num_hwqs = afu->desired_hwqs;
2109 for (i = 0; i < afu->num_hwqs; i++) {
2119 hwq = get_hwq(afu, PRIMARY_HWQ);
2120 afu->afu_map = cfg->ops->psa_map(hwq->ctx_cookie);
2121 if (!afu->afu_map) {
2128 reg = readq(&afu->afu_map->global.regs.afu_version);
2129 memcpy(afu->version, &reg, sizeof(reg));
2130 afu->interface_version =
2131 readq_be(&afu->afu_map->global.regs.interface_version);
2132 if ((afu->interface_version + 1) == 0) {
2134 "interface version %016llx\n", afu->version,
2135 afu->interface_version);
2140 if (afu_is_sq_cmd_mode(afu)) {
2141 afu->send_cmd = send_cmd_sq;
2142 afu->context_reset = context_reset_sq;
2144 afu->send_cmd = send_cmd_ioarrin;
2145 afu->context_reset = context_reset_ioarrin;
2149 afu->version, afu->interface_version);
2159 afu_err_intr_init(cfg->afu);
2160 for (i = 0; i < afu->num_hwqs; i++) {
2161 hwq = get_hwq(afu, i);
2173 for (i = afu->num_hwqs - 1; i >= 0; i--) {
2267 * @afu: AFU associated with the host.
2281 static int send_afu_cmd(struct afu *afu, struct sisl_ioarcb *rcb)
2283 struct cxlflash_cfg *cfg = afu->parent;
2286 struct hwq *hwq = get_hwq(afu, PRIMARY_HWQ);
2298 mutex_lock(&afu->sync_active);
2299 atomic_inc(&afu->cmds_active);
2314 cmd->parent = afu;
2318 dev_dbg(dev, "%s: afu=%p cmd=%p type=%02x nretry=%d\n",
2319 __func__, afu, cmd, cmd->rcb.cdb[0], nretry);
2321 rc = afu->send_cmd(afu, cmd);
2327 rc = wait_resp(afu, cmd);
2330 rc = afu->context_reset(hwq);
2352 atomic_dec(&afu->cmds_active);
2353 mutex_unlock(&afu->sync_active);
2361 * @afu: AFU associated with the host.
2375 int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx, res_hndl_t res, u8 mode)
2377 struct cxlflash_cfg *cfg = afu->parent;
2381 dev_dbg(dev, "%s: afu=%p ctx=%u res=%u mode=%u\n",
2382 __func__, afu, ctx, res, mode);
2393 return send_afu_cmd(afu, &rcb);
2413 struct afu *afu = cfg->afu;
2414 struct hwq *hwq = get_hwq(afu, cmd->hwq_index);
2433 rc = afu->context_reset(hwq);
2671 struct afu *afu = cfg->afu;
2673 return scnprintf(buf, PAGE_SIZE, "%u\n", afu->internal_lun);
2704 struct afu *afu = cfg->afu;
2709 if (!rc && (lun_mode < 5) && (lun_mode != afu->internal_lun)) {
2710 afu->internal_lun = lun_mode;
2717 if (afu->internal_lun)
2867 struct afu *afu = cfg->afu;
2869 return scnprintf(buf, PAGE_SIZE, "%u\n", afu->irqpoll_weight);
2890 struct afu *afu = cfg->afu;
2905 if (weight == afu->irqpoll_weight) {
2911 if (afu_is_irqpoll_enabled(afu)) {
2912 for (i = 0; i < afu->num_hwqs; i++) {
2913 hwq = get_hwq(afu, i);
2919 afu->irqpoll_weight = weight;
2922 for (i = 0; i < afu->num_hwqs; i++) {
2923 hwq = get_hwq(afu, i);
2945 struct afu *afu = cfg->afu;
2947 return scnprintf(buf, PAGE_SIZE, "%u\n", afu->num_hwqs);
2969 struct afu *afu = cfg->afu;
2984 afu->desired_hwqs = min(num_hwqs, CXLFLASH_MAX_HWQS);
2985 WARN_ON_ONCE(afu->desired_hwqs == 0);
3030 struct afu *afu = cfg->afu;
3032 return scnprintf(buf, PAGE_SIZE, "%s\n", hwq_mode_name[afu->hwq_mode]);
3056 struct afu *afu = cfg->afu;
3072 afu->hwq_mode = mode;
3205 struct afu *afu = cfg->afu;
3229 afu_link_reset(afu, port, fc_port_regs);
3290 struct afu *afu = cfg->afu;
3303 if (!afu_is_lun_provision(afu)) {
3355 rc = send_afu_cmd(afu, &rcb);
3384 struct afu *afu = cfg->afu;
3396 if (!afu_is_afu_debug(afu)) {
3444 rc = send_afu_cmd(afu, &rcb);