qla2x00t-32gbit: Backport to RHEL 6

Untested.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8169 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2019-04-06 23:21:29 +00:00
parent a0d61a5d2a
commit e8509800b2
5 changed files with 358 additions and 2 deletions
+286
View File
@@ -0,0 +1,286 @@
#ifndef _BTREE_BACKPORT_H_
#define _BTREE_BACKPORT_H_
struct btree_head32 {
struct list_head head;
};
struct btree_node32 {
struct list_head entry;
u32 key;
void *val;
};
struct btree_head64 {
struct list_head head;
};
struct btree_node64 {
struct list_head entry;
u64 key;
void *val;
};
/**
* btree_init - initialise a btree
*
* @head: the btree head to initialise
*
* This function allocates the memory pool that the
* btree needs. Returns zero or a negative error code
* (-%ENOMEM) when memory allocation fails.
*/
static inline int __must_check btree_init32(struct btree_head32 *head)
{
INIT_LIST_HEAD(&head->head);
return 0;
}
static inline int __must_check btree_init64(struct btree_head64 *head)
{
INIT_LIST_HEAD(&head->head);
return 0;
}
/**
* btree_destroy - destroy mempool
*
* @head: the btree head to destroy
*
* This function destroys the internal memory pool, use only
* when using btree_init(), not with btree_init_mempool().
*/
static inline void btree_destroy32(struct btree_head32 *head)
{
}
static inline void btree_destroy64(struct btree_head64 *head)
{
}
/**
* btree_lookup - look up a key in the btree
*
* @head: the btree to look in
* @geo: the btree geometry
* @key: the key to look up
*
* This function returns the value for the given key, or %NULL.
*/
static inline void *btree_lookup32(struct btree_head32 *head, u32 key)
{
struct btree_node32 *n;
list_for_each_entry(n, &head->head, entry) {
if (n->key == key)
return n->val;
}
return NULL;
}
static inline void *btree_lookup64(struct btree_head64 *head, u64 key)
{
struct btree_node64 *n;
list_for_each_entry(n, &head->head, entry) {
if (n->key == key)
return n->val;
}
return NULL;
}
/**
* btree_insert - insert an entry into the btree
*
* @head: the btree to add to
* @geo: the btree geometry
* @key: the key to add (must not already be present)
* @val: the value to add (must not be %NULL)
* @gfp: allocation flags for node allocations
*
* This function returns 0 if the item could be added, or an
* error code if it failed (may fail due to memory pressure).
*/
static inline int __must_check btree_insert32(struct btree_head32 *head,
u32 key, void *val, gfp_t gfp)
{
struct btree_node32 *n, *p;
n = kmalloc(sizeof(*n), gfp);
if (IS_ERR(n))
return PTR_ERR(n);
n->key = key;
n->val = val;
list_for_each_entry(p, &head->head, entry) {
if (p->key > key)
break;
}
list_add(p->entry.prev, &n->entry);
return 0;
}
static inline int __must_check btree_insert64(struct btree_head64 *head,
u64 key, void *val, gfp_t gfp)
{
struct btree_node64 *n, *p;
n = kmalloc(sizeof(*n), gfp);
if (IS_ERR(n))
return PTR_ERR(n);
n->key = key;
n->val = val;
list_for_each_entry(p, &head->head, entry) {
if (p->key > key)
break;
}
list_add(p->entry.prev, &n->entry);
return 0;
}
/**
* btree_update - update an entry in the btree
*
* @head: the btree to update
* @geo: the btree geometry
* @key: the key to update
* @val: the value to change it to (must not be %NULL)
*
* This function returns 0 if the update was successful, or
* -%ENOENT if the key could not be found.
*/
static inline int btree_update32(struct btree_head32 *head, u32 key, void *val)
{
struct btree_node32 *p;
list_for_each_entry(p, &head->head, entry) {
if (p->key == key) {
p->val = val;
return 0;
}
}
return -ENOENT;
}
/**
* btree_remove - remove an entry from the btree
*
* @head: the btree to update
* @geo: the btree geometry
* @key: the key to remove
*
* This function returns the removed entry, or %NULL if the key
* could not be found.
*/
static inline void *btree_remove32(struct btree_head32 *head, u32 key)
{
struct btree_node32 *p;
void *val;
list_for_each_entry(p, &head->head, entry) {
if (p->key == key) {
val = p->val;
list_del(&p->entry);
kfree(p);
return val;
}
}
return NULL;
}
static inline void *btree_remove64(struct btree_head64 *head, u64 key)
{
struct btree_node64 *p;
void *val;
list_for_each_entry(p, &head->head, entry) {
if (p->key == key) {
val = p->val;
list_del(&p->entry);
kfree(p);
return val;
}
}
return NULL;
}
/**
* btree_last - get last entry in btree
*
* @head: btree head
* @geo: btree geometry
* @key: last key
*
* Returns the last entry in the btree, and sets @key to the key
* of that entry; returns NULL if the tree is empty, in that case
* key is not changed.
*/
static inline void *btree_last32(struct btree_head32 *head, u32 *key)
{
struct btree_node32 *p;
if (list_empty(&head->head))
return NULL;
p = list_last_entry(&head->head, typeof(*p), entry);
*key = p->key;
return p->val;
}
static inline void *btree_last64(struct btree_head64 *head, u64 *key)
{
struct btree_node64 *p;
if (list_empty(&head->head))
return NULL;
p = list_last_entry(&head->head, typeof(*p), entry);
*key = p->key;
return p->val;
}
/**
* btree_get_prev - get previous entry
*
* @head: btree head
* @geo: btree geometry
* @key: pointer to key
*
* The function returns the next item right before the value pointed to by
* @key, and updates @key with its key, or returns %NULL when there is no
* entry with a key smaller than the given key.
*/
static inline void *btree_get_prev32(struct btree_head32 *head, u32 *key)
{
struct btree_node32 *p;
list_for_each_entry_reverse(p, &head->head, entry) {
if (p->key < *key) {
*key = p->key;
return p->val;
}
}
return NULL;
}
static inline void *btree_get_prev64(struct btree_head64 *head, u64 *key)
{
struct btree_node64 *p;
list_for_each_entry_reverse(p, &head->head, entry) {
if (p->key < *key) {
*key = p->key;
return p->val;
}
}
return NULL;
}
#define btree_for_each_safe32(head, key, val) \
for (val = btree_last32(head, &key); \
val; \
val = btree_get_prev32(head, &key))
#define btree_for_each_safe64(head, key, val) \
for (val = btree_last64(head, &key); \
val; \
val = btree_get_prev64(head, &key))
#endif /* _BTREE_BACKPORT_H_ */
+8 -1
View File
@@ -25,8 +25,15 @@
#include <linux/firmware.h>
#include <linux/aer.h>
#include <linux/mutex.h>
#include <linux/btree.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
/*
* See also commit 5db53f3e80de ("[LogFS] add new flash file system") # v2.6.34.
*/
#include <linux/btree.h>
#else
#include "btree-backport.h"
#endif
#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
+27 -1
View File
@@ -13,13 +13,14 @@
#include <linux/mutex.h>
#include <linux/kobject.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
#include <linux/blk-mq-pci.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
#include <linux/refcount.h>
#endif
#include <linux/version.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsicam.h>
@@ -331,7 +332,13 @@ static int qla2xxx_slave_alloc(struct scsi_device *);
static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time);
static void qla2xxx_scan_start(struct Scsi_Host *);
static void qla2xxx_slave_destroy(struct scsi_device *);
#if defined(RHEL_MAJOR) && RHEL_MAJOR -0 == 6 && RHEL_MINOR -0 >= 2
static int qla2xxx_queuecommand(struct scsi_cmnd *scmnd,
void (*done)(struct scsi_cmnd *));
#else
static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
#endif
static int qla2xxx_eh_abort(struct scsi_cmnd *);
static int qla2xxx_eh_device_reset(struct scsi_cmnd *);
static int qla2xxx_eh_target_reset(struct scsi_cmnd *);
@@ -924,8 +931,23 @@ qla2xxx_qpair_sp_compl(void *ptr, int res)
cmd->scsi_done(cmd);
}
#if defined(RHEL_MAJOR) && RHEL_MAJOR -0 == 6 && RHEL_MINOR -0 >= 2
static int
qla2xxx_queuecommand_wrk(struct Scsi_Host *host, struct scsi_cmnd *cmd);
static int qla2xxx_queuecommand(struct scsi_cmnd *scmnd,
void (*done)(struct scsi_cmnd *))
{
scmnd->scsi_done = done;
return qla2xxx_queuecommand_wrk(scmnd->device->host, scmnd);
}
static int
qla2xxx_queuecommand_wrk(struct Scsi_Host *host, struct scsi_cmnd *cmd)
#else
static int
qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
#endif
{
scsi_qla_host_t *vha = shost_priv(host);
fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
@@ -5061,7 +5083,11 @@ void qla24xx_sched_upd_fcport(fc_port_t *fcport)
fcport->disc_state = DSC_UPD_FCPORT;
spin_unlock_irqrestore(&fcport->vha->work_lock, flags);
#if defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 6
schedule_work(&fcport->reg_work);
#else
queue_work(system_unbound_wq, &fcport->reg_work);
#endif
}
static
+8
View File
@@ -738,7 +738,15 @@ struct qla_tgt_func_tmpl {
int qla2x00_wait_for_hba_online(struct scsi_qla_host *);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
/*
* See also commit c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0")
* # v2.6.38.
*/
#include <target/target_core_base.h>
#else
#include "target_core_base-backport.h"
#endif
#define QLA_TGT_TIMEOUT 10 /* in seconds */
@@ -0,0 +1,29 @@
#ifndef _TARGET_CORE_BASE_BACKPORT_H_
#define _TARGET_CORE_BASE_BACKPORT_H_
#define TRANSPORT_SENSE_BUFFER 96
enum se_cmd_flags_table {
SCF_OVERFLOW_BIT = 0x00001000,
SCF_UNDERFLOW_BIT = 0x00002000,
};
/* for sam_task_attr */
#define TCM_SIMPLE_TAG 0x20
#define TCM_HEAD_TAG 0x21
#define TCM_ORDERED_TAG 0x22
#define TCM_ACA_TAG 0x24
struct se_cmd {
u64 tag; /* SAM command identifier aka task tag */
u32 se_cmd_flags;
u32 residual_count;
u64 t_task_lba;
int cpuid;
};
struct se_session {
void *fabric_sess_ptr;
};
#endif /* _TARGET_CORE_BASE_BACKPORT_H_ */