Page MenuHomeFreeBSD

D32304.diff
No OneTemporary

D32304.diff

diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h
--- a/sys/cam/cam_ccb.h
+++ b/sys/cam/cam_ccb.h
@@ -422,13 +422,12 @@
};
typedef enum {
- PERIPH_MATCH_NONE = 0x000,
+ PERIPH_MATCH_ANY = 0x000,
PERIPH_MATCH_PATH = 0x001,
PERIPH_MATCH_TARGET = 0x002,
PERIPH_MATCH_LUN = 0x004,
PERIPH_MATCH_NAME = 0x008,
PERIPH_MATCH_UNIT = 0x010,
- PERIPH_MATCH_ANY = 0x01f
} periph_pattern_flags;
struct periph_match_pattern {
@@ -441,13 +440,12 @@
};
typedef enum {
- DEV_MATCH_NONE = 0x000,
+ DEV_MATCH_ANY = 0x000,
DEV_MATCH_PATH = 0x001,
DEV_MATCH_TARGET = 0x002,
DEV_MATCH_LUN = 0x004,
DEV_MATCH_INQUIRY = 0x008,
DEV_MATCH_DEVID = 0x010,
- DEV_MATCH_ANY = 0x00f
} dev_pattern_flags;
struct device_id_match_pattern {
@@ -467,12 +465,11 @@
};
typedef enum {
- BUS_MATCH_NONE = 0x000,
+ BUS_MATCH_ANY = 0x000,
BUS_MATCH_PATH = 0x001,
BUS_MATCH_NAME = 0x002,
BUS_MATCH_UNIT = 0x004,
BUS_MATCH_BUS_ID = 0x008,
- BUS_MATCH_ANY = 0x00f
} bus_pattern_flags;
struct bus_match_pattern {
@@ -594,7 +591,7 @@
/*
* Definitions for the path inquiry CCB fields.
*/
-#define CAM_VERSION 0x19 /* Hex value for current version */
+#define CAM_VERSION 0x1a /* Hex value for current version */
typedef enum {
PI_MDP_ABLE = 0x80, /* Supports MDP message */
diff --git a/sys/cam/cam_compat.h b/sys/cam/cam_compat.h
--- a/sys/cam/cam_compat.h
+++ b/sys/cam/cam_compat.h
@@ -220,5 +220,12 @@
#define CAMIOCOMMAND_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 2, CAM_0X18_LEN)
#define CAMGETPASSTHRU_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 3, CAM_0X18_LEN)
+/* Version 0x19 compatibility */
+#define CAM_VERSION_0x19 0x19
+#define CAMIOCOMMAND_0x19 _IOWR(CAM_VERSION_0x19, 2, union ccb)
+#define CAMGETPASSTHRU_0x19 _IOWR(CAM_VERSION_0x19, 3, union ccb)
+#define CAMIOQUEUE_0x19 _IO(CAM_VERSION_0x19, 4)
+#define CAMIOGET_0x19 _IO(CAM_VERSION_0x19, 5)
+
#endif
#endif
diff --git a/sys/cam/cam_compat.c b/sys/cam/cam_compat.c
--- a/sys/cam/cam_compat.c
+++ b/sys/cam/cam_compat.c
@@ -58,6 +58,8 @@
int flag, struct thread *td, d_ioctl_t *cbfnp);
static int cam_compat_handle_0x18(struct cdev *dev, u_long cmd, caddr_t addr,
int flag, struct thread *td, d_ioctl_t *cbfnp);
+static int cam_compat_handle_0x19(struct cdev *dev, u_long cmd, caddr_t addr,
+ int flag, struct thread *td, d_ioctl_t *cbfnp);
static int cam_compat_translate_dev_match_0x18(union ccb *ccb);
int
@@ -108,6 +110,22 @@
cmd = CAMGETPASSTHRU;
error = cam_compat_handle_0x18(dev, cmd, addr, flag, td, cbfnp);
break;
+ case CAMIOCOMMAND_0x19:
+ cmd = CAMIOCOMMAND;
+ error = cam_compat_handle_0x19(dev, cmd, addr, flag, td, cbfnp);
+ break;
+ case CAMGETPASSTHRU_0x19:
+ cmd = CAMGETPASSTHRU;
+ error = cam_compat_handle_0x19(dev, cmd, addr, flag, td, cbfnp);
+ break;
+ case CAMIOQUEUE_0x19:
+ cmd = CAMIOQUEUE;
+ error = cam_compat_handle_0x19(dev, cmd, addr, flag, td, cbfnp);
+ break;
+ case CAMIOGET_0x19:
+ cmd = CAMIOGET;
+ error = cam_compat_handle_0x19(dev, cmd, addr, flag, td, cbfnp);
+ break;
default:
error = ENOTTY;
}
@@ -170,7 +188,7 @@
bcopy(ccbb17, ccbb, CAM_0X17_DATA_LEN);
}
- error = (cbfnp)(dev, cmd, (caddr_t)ccb, flag, td);
+ error = cam_compat_handle_0x19(dev, cmd, (caddr_t)ccb, flag, td, cbfnp);
hdr17->pinfo = hdr->pinfo;
hdr17->xpt_links = hdr->xpt_links;
@@ -310,7 +328,7 @@
bcopy(ccbb18, ccbb, CAM_0X18_DATA_LEN);
}
- error = (cbfnp)(dev, cmd, (caddr_t)ccb, flag, td);
+ error = cam_compat_handle_0x19(dev, cmd, (caddr_t)ccb, flag, td, cbfnp);
hdr18->pinfo = hdr->pinfo;
hdr18->xpt_links = hdr->xpt_links;
@@ -420,3 +438,31 @@
return (0);
}
+
+static int
+cam_compat_handle_0x19(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
+ struct thread *td, d_ioctl_t *cbfnp)
+{
+ union ccb *ccb = (union ccb *)addr;
+ struct cam_periph_map_info mapinfo;
+
+ if (cmd == CAMIOCOMMAND && ccb->ccb_h.func_code == XPT_DEV_MATCH) {
+ bzero(&mapinfo, sizeof(mapinfo));
+ cam_periph_mapmem(ccb, &mapinfo, maxphys);
+ for (int i = 0; i < ccb->cdm.num_patterns; i++) {
+ struct dev_match_pattern *p = &ccb->cdm.patterns[i];
+
+ if (p->type == DEV_MATCH_BUS &&
+ p->pattern.bus_pattern.flags == 0x00f)
+ p->pattern.bus_pattern.flags = BUS_MATCH_ANY;
+ if (p->type == DEV_MATCH_DEVICE &&
+ p->pattern.device_pattern.flags == 0x00f)
+ p->pattern.device_pattern.flags = DEV_MATCH_ANY;
+ if (p->type == DEV_MATCH_PERIPH &&
+ p->pattern.periph_pattern.flags == 0x01f)
+ p->pattern.periph_pattern.flags = PERIPH_MATCH_ANY;
+ }
+ cam_periph_unmapmem(ccb, &mapinfo);
+ }
+ return ((cbfnp)(dev, cmd, addr, flag, td));
+}
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -1386,6 +1386,8 @@
for (i = 0; i < num_patterns; i++) {
struct bus_match_pattern *cur_pattern;
+ struct device_match_pattern *dp = &patterns[i].pattern.device_pattern;
+ struct periph_match_pattern *pp = &patterns[i].pattern.periph_pattern;
/*
* If the pattern in question isn't for a bus node, we
@@ -1394,6 +1396,14 @@
* tree, since the user wants to match against lower-level
* EDT elements.
*/
+ if (patterns[i].type == DEV_MATCH_DEVICE &&
+ (dp->flags & DEV_MATCH_PATH) != 0 &&
+ dp->path_id != bus->path_id)
+ continue;
+ if (patterns[i].type == DEV_MATCH_PERIPH &&
+ (pp->flags & PERIPH_MATCH_PATH) != 0 &&
+ pp->path_id != bus->path_id)
+ continue;
if (patterns[i].type != DEV_MATCH_BUS) {
if ((retval & DM_RET_ACTION_MASK) == DM_RET_NONE)
retval |= DM_RET_DESCEND;
@@ -1402,28 +1412,6 @@
cur_pattern = &patterns[i].pattern.bus_pattern;
- /*
- * If they want to match any bus node, we give them any
- * device node.
- */
- if (cur_pattern->flags == BUS_MATCH_ANY) {
- /* set the copy flag */
- retval |= DM_RET_COPY;
-
- /*
- * If we've already decided on an action, go ahead
- * and return.
- */
- if ((retval & DM_RET_ACTION_MASK) != DM_RET_NONE)
- return(retval);
- }
-
- /*
- * Not sure why someone would do this...
- */
- if (cur_pattern->flags == BUS_MATCH_NONE)
- continue;
-
if (((cur_pattern->flags & BUS_MATCH_PATH) != 0)
&& (cur_pattern->path_id != bus->path_id))
continue;
@@ -1499,11 +1487,20 @@
for (i = 0; i < num_patterns; i++) {
struct device_match_pattern *cur_pattern;
struct scsi_vpd_device_id *device_id_page;
+ struct periph_match_pattern *pp = &patterns[i].pattern.periph_pattern;
/*
* If the pattern in question isn't for a device node, we
* aren't interested.
*/
+ if (patterns[i].type == DEV_MATCH_PERIPH &&
+ (pp->flags & PERIPH_MATCH_TARGET) != 0 &&
+ pp->target_id != device->target->target_id)
+ continue;
+ if (patterns[i].type == DEV_MATCH_PERIPH &&
+ (pp->flags & PERIPH_MATCH_LUN) != 0 &&
+ pp->target_lun != device->lun_id)
+ continue;
if (patterns[i].type != DEV_MATCH_DEVICE) {
if ((patterns[i].type == DEV_MATCH_PERIPH)
&& ((retval & DM_RET_ACTION_MASK) == DM_RET_NONE))
@@ -1518,19 +1515,6 @@
== (DEV_MATCH_INQUIRY|DEV_MATCH_DEVID))
return(DM_RET_ERROR);
- /*
- * If they want to match any device node, we give them any
- * device node.
- */
- if (cur_pattern->flags == DEV_MATCH_ANY)
- goto copy_dev_node;
-
- /*
- * Not sure why someone would do this...
- */
- if (cur_pattern->flags == DEV_MATCH_NONE)
- continue;
-
if (((cur_pattern->flags & DEV_MATCH_PATH) != 0)
&& (cur_pattern->path_id != device->target->bus->path_id))
continue;
@@ -1560,7 +1544,6 @@
cur_pattern->data.devid_pat.id_len) != 0))
continue;
-copy_dev_node:
/*
* If we get to this point, the user definitely wants
* information on this device. So tell the caller to copy
@@ -1635,27 +1618,6 @@
cur_pattern = &patterns[i].pattern.periph_pattern;
- /*
- * If they want to match on anything, then we will do so.
- */
- if (cur_pattern->flags == PERIPH_MATCH_ANY) {
- /* set the copy flag */
- retval |= DM_RET_COPY;
-
- /*
- * We've already set the return action to stop,
- * since there are no nodes below peripherals in
- * the tree.
- */
- return(retval);
- }
-
- /*
- * Not sure why someone would do this...
- */
- if (cur_pattern->flags == PERIPH_MATCH_NONE)
- continue;
-
if (((cur_pattern->flags & PERIPH_MATCH_PATH) != 0)
&& (cur_pattern->path_id != periph->path->bus->path_id))
continue;

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 12, 6:45 PM (20 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15772089
Default Alt Text
D32304.diff (8 KB)

Event Timeline