Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixl/ixl_iw.c
/****************************************************************************** | /****************************************************************************** | ||||
Copyright (c) 2013-2015, Intel Corporation | Copyright (c) 2013-2017, Intel Corporation | ||||
All rights reserved. | All rights reserved. | ||||
Redistribution and use in source and binary forms, with or without | Redistribution and use in source and binary forms, with or without | ||||
modification, are permitted provided that the following conditions are met: | modification, are permitted provided that the following conditions are met: | ||||
1. Redistributions of source code must retain the above copyright notice, | 1. Redistributions of source code must retain the above copyright notice, | ||||
this list of conditions and the following disclaimer. | this list of conditions and the following disclaimer. | ||||
▲ Show 20 Lines • Show All 357 Lines • ▼ Show 20 Lines | ixl_iw_pf_msix_init(void *pf_handle, | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
ixl_iw_register(struct ixl_iw_ops *ops) | ixl_iw_register(struct ixl_iw_ops *ops) | ||||
{ | { | ||||
struct ixl_iw_pf_entry *pf_entry; | struct ixl_iw_pf_entry *pf_entry; | ||||
int err = 0; | int err = 0; | ||||
int iwarp_cap_on_pfs = 0; | |||||
INIT_DEBUGOUT("begin"); | INIT_DEBUGOUT("begin"); | ||||
LIST_FOREACH(pf_entry, &ixl_iw.pfs, node) | |||||
iwarp_cap_on_pfs += pf_entry->pf->hw.func_caps.iwarp; | |||||
if (!iwarp_cap_on_pfs && ixl_enable_iwarp) { | |||||
printf("%s: the device is not iwarp-capable, registering dropped\n", | |||||
__func__); | |||||
return (ENODEV); | |||||
} | |||||
if (ixl_enable_iwarp == 0) { | if (ixl_enable_iwarp == 0) { | ||||
printf("%s: enable_iwarp is off, registering dropped\n", | printf("%s: enable_iwarp is off, registering dropped\n", | ||||
__func__); | __func__); | ||||
return (EACCES); | return (EACCES); | ||||
} | } | ||||
if ((ops->init == NULL) || (ops->stop == NULL)) { | if ((ops->init == NULL) || (ops->stop == NULL)) { | ||||
printf("%s: invalid iwarp driver ops\n", __func__); | printf("%s: invalid iwarp driver ops\n", __func__); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
mtx_lock(&ixl_iw.mtx); | mtx_lock(&ixl_iw.mtx); | ||||
if (ixl_iw.registered) { | if (ixl_iw.registered) { | ||||
printf("%s: iwarp driver already registered\n", __func__); | printf("%s: iwarp driver already registered\n", __func__); | ||||
err = EBUSY; | err = (EBUSY); | ||||
goto out; | goto out; | ||||
} | } | ||||
ixl_iw.registered = true; | |||||
mtx_unlock(&ixl_iw.mtx); | |||||
ixl_iw.tq = taskqueue_create("ixl_iw", M_NOWAIT, | ixl_iw.tq = taskqueue_create("ixl_iw", M_NOWAIT, | ||||
taskqueue_thread_enqueue, &ixl_iw.tq); | taskqueue_thread_enqueue, &ixl_iw.tq); | ||||
if (ixl_iw.tq == NULL) { | if (ixl_iw.tq == NULL) { | ||||
printf("%s: failed to create queue\n", __func__); | printf("%s: failed to create queue\n", __func__); | ||||
err = ENOMEM; | ixl_iw.registered = false; | ||||
goto out; | return (ENOMEM); | ||||
} | } | ||||
taskqueue_start_threads(&ixl_iw.tq, 1, PI_NET, "ixl iw"); | taskqueue_start_threads(&ixl_iw.tq, 1, PI_NET, "ixl iw"); | ||||
ixl_iw.ops = malloc(sizeof(struct ixl_iw_ops), | ixl_iw.ops = malloc(sizeof(struct ixl_iw_ops), | ||||
M_DEVBUF, M_NOWAIT | M_ZERO); | M_DEVBUF, M_NOWAIT | M_ZERO); | ||||
if (ixl_iw.ops == NULL) { | if (ixl_iw.ops == NULL) { | ||||
printf("%s: failed to allocate memory\n", __func__); | printf("%s: failed to allocate memory\n", __func__); | ||||
taskqueue_free(ixl_iw.tq); | taskqueue_free(ixl_iw.tq); | ||||
err = ENOMEM; | ixl_iw.registered = false; | ||||
goto out; | return (ENOMEM); | ||||
} | } | ||||
ixl_iw.ops->init = ops->init; | ixl_iw.ops->init = ops->init; | ||||
ixl_iw.ops->stop = ops->stop; | ixl_iw.ops->stop = ops->stop; | ||||
ixl_iw.registered = true; | |||||
mtx_lock(&ixl_iw.mtx); | |||||
LIST_FOREACH(pf_entry, &ixl_iw.pfs, node) | LIST_FOREACH(pf_entry, &ixl_iw.pfs, node) | ||||
if (pf_entry->state.pf == IXL_IW_PF_STATE_ON) { | if (pf_entry->state.pf == IXL_IW_PF_STATE_ON) { | ||||
pf_entry->state.iw_scheduled = IXL_IW_PF_STATE_ON; | pf_entry->state.iw_scheduled = IXL_IW_PF_STATE_ON; | ||||
taskqueue_enqueue(ixl_iw.tq, &pf_entry->iw_task); | taskqueue_enqueue(ixl_iw.tq, &pf_entry->iw_task); | ||||
} | } | ||||
out: | out: | ||||
mtx_unlock(&ixl_iw.mtx); | mtx_unlock(&ixl_iw.mtx); | ||||
return (err); | return (err); | ||||
} | } | ||||
int | int | ||||
ixl_iw_unregister(void) | ixl_iw_unregister(void) | ||||
{ | { | ||||
struct ixl_iw_pf_entry *pf_entry; | struct ixl_iw_pf_entry *pf_entry; | ||||
int iwarp_cap_on_pfs = 0; | |||||
INIT_DEBUGOUT("begin"); | INIT_DEBUGOUT("begin"); | ||||
LIST_FOREACH(pf_entry, &ixl_iw.pfs, node) | |||||
iwarp_cap_on_pfs += pf_entry->pf->hw.func_caps.iwarp; | |||||
if (!iwarp_cap_on_pfs && ixl_enable_iwarp) { | |||||
printf("%s: attempt to unregister driver when no iwarp-capable device present\n", | |||||
__func__); | |||||
return (ENODEV); | |||||
} | |||||
if (ixl_enable_iwarp == 0) { | |||||
printf("%s: attempt to unregister driver when enable_iwarp is off\n", | |||||
__func__); | |||||
return (ENODEV); | |||||
} | |||||
mtx_lock(&ixl_iw.mtx); | mtx_lock(&ixl_iw.mtx); | ||||
if (!ixl_iw.registered) { | if (!ixl_iw.registered) { | ||||
printf("%s: failed - iwarp driver has not been registered\n", | printf("%s: failed - iwarp driver has not been registered\n", | ||||
__func__); | __func__); | ||||
mtx_unlock(&ixl_iw.mtx); | mtx_unlock(&ixl_iw.mtx); | ||||
return (ENOENT); | return (ENOENT); | ||||
} | } | ||||
Show All 22 Lines |