Lines Matching +full:local +full:- +full:host
1 // SPDX-License-Identifier: GPL-2.0-or-later
25 * create_local() - allocate and initialize a local LUN information structure
29 * Return: Allocated local llun_info structure on success, NULL on failure
33 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in create_local()
34 struct device *dev = &cfg->dev->dev; in create_local()
43 lli->sdev = sdev; in create_local()
44 lli->host_no = sdev->host->host_no; in create_local()
45 lli->in_table = false; in create_local()
47 memcpy(lli->wwid, wwid, DK_CXLFLASH_MANAGE_LUN_WWID_LEN); in create_local()
53 * create_global() - allocate and initialize a global LUN information structure
61 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in create_global()
62 struct device *dev = &cfg->dev->dev; in create_global()
71 mutex_init(&gli->mutex); in create_global()
72 memcpy(gli->wwid, wwid, DK_CXLFLASH_MANAGE_LUN_WWID_LEN); in create_global()
78 * lookup_local() - find a local LUN information structure by WWID
79 * @cfg: Internal structure associated with the host.
82 * Return: Found local lun_info structure on success, NULL on failure
88 list_for_each_entry_safe(lli, temp, &cfg->lluns, list) in lookup_local()
89 if (!memcmp(lli->wwid, wwid, DK_CXLFLASH_MANAGE_LUN_WWID_LEN)) in lookup_local()
96 * lookup_global() - find a global LUN information structure by WWID
106 if (!memcmp(gli->wwid, wwid, DK_CXLFLASH_MANAGE_LUN_WWID_LEN)) in lookup_global()
113 * find_and_create_lun() - find or create a local LUN information structure
117 * The LUN is kept both in a local list (per adapter) and in a global list
118 * (across all adapters). Certain attributes of the LUN are local to the
124 * LUN (one local, one global).
126 * Keep a pointer back from the local to the global entry.
130 * Return: Found/Allocated local lun_info structure on success, NULL on failure
134 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in find_and_create_lun()
135 struct device *dev = &cfg->dev->dev; in find_and_create_lun()
152 lli->parent = gli; in find_and_create_lun()
153 list_add(&lli->list, &cfg->lluns); in find_and_create_lun()
164 lli->parent = gli; in find_and_create_lun()
165 list_add(&lli->list, &cfg->lluns); in find_and_create_lun()
167 list_add(&gli->list, &global.gluns); in find_and_create_lun()
175 * cxlflash_term_local_luns() - Delete all entries from local LUN list, free.
176 * @cfg: Internal structure associated with the host.
183 list_for_each_entry_safe(lli, temp, &cfg->lluns, list) { in cxlflash_term_local_luns()
184 list_del(&lli->list); in cxlflash_term_local_luns()
191 * cxlflash_list_init() - initializes the global LUN list
201 * cxlflash_term_global_luns() - frees resources associated with global LUN list
209 list_del(&gli->list); in cxlflash_term_global_luns()
210 cxlflash_ba_terminate(&gli->blka.ba_lun); in cxlflash_term_global_luns()
217 * cxlflash_manage_lun() - handles LUN management activities
225 * Return: 0 on success, -errno on failure
230 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in cxlflash_manage_lun()
231 struct device *dev = &cfg->dev->dev; in cxlflash_manage_lun()
234 u64 flags = manage->hdr.flags; in cxlflash_manage_lun()
235 u32 chan = sdev->channel; in cxlflash_manage_lun()
238 lli = find_and_create_lun(sdev, manage->wwid); in cxlflash_manage_lun()
240 __func__, get_unaligned_be64(&manage->wwid[0]), in cxlflash_manage_lun()
241 get_unaligned_be64(&manage->wwid[8]), manage->hdr.flags, lli); in cxlflash_manage_lun()
243 rc = -ENOMEM; in cxlflash_manage_lun()
250 * in unpacked, AFU-friendly format, and hang LUN reference in in cxlflash_manage_lun()
253 lli->port_sel |= CHAN2PORTMASK(chan); in cxlflash_manage_lun()
254 lli->lun_id[chan] = lun_to_lunid(sdev->lun); in cxlflash_manage_lun()
255 sdev->hostdata = lli; in cxlflash_manage_lun()
257 if (lli->parent->mode != MODE_NONE) in cxlflash_manage_lun()
258 rc = -EBUSY; in cxlflash_manage_lun()
261 * Clean up local LUN for this port and reset table in cxlflash_manage_lun()
264 sdev->hostdata = NULL; in cxlflash_manage_lun()
265 lli->port_sel &= ~CHAN2PORTMASK(chan); in cxlflash_manage_lun()
266 if (lli->port_sel == 0U) in cxlflash_manage_lun()
267 lli->in_table = false; in cxlflash_manage_lun()
272 __func__, lli->port_sel, chan, lli->lun_id[chan]); in cxlflash_manage_lun()