Thread: [Linux1394-cvslog] rev 836 - trunk
Brought to you by:
aeb,
bencollins
From: SVN U. <ben...@li...> - 2003-03-12 02:44:54
|
Author: bencollins Date: 2003-03-11 21:44:04 -0500 (Tue, 11 Mar 2003) New Revision: 836 Modified: trunk/TODO trunk/nodemgr.c trunk/nodemgr.h Log: Convert over to using guid as the node. Handle rescan's and node changes better. Modified: trunk/nodemgr.c ============================================================================== --- trunk/nodemgr.c (original) +++ trunk/nodemgr.c 2003-03-11 21:44:05.000000000 -0500 @@ -31,9 +31,14 @@ #include "nodemgr.h" -/* Shitty part is, 0x0 can just mean it wasn't set, but that matches an - * OUI entry. We don't want that, so we take a chance and never match 0x0. - * Sorry XEROX. */ +#if 1 +#define FW_BUS_ID_FMT "%012Lx" +#define FW_BUS_ID_ARGS(__hi, __ne) (unsigned long long)__ne->guid & 0xffffffffffff +#else +#define FW_BUS_ID_FMT "%d-" NODE_BUS_FMT +#define FW_BUS_ID_ARGS(__hi, __ne) __hi->id, NODE_BUS_ARGS(__ne->nodeid) +#endif + static char *nodemgr_find_oui_name(int oui) { #ifdef CONFIG_IEEE1394_OUI_DB @@ -43,7 +48,7 @@ } oui_list[]; int i; - for (i = 1; oui_list[i].name; i++) + for (i = 0; oui_list[i].name; i++) if (oui_list[i].oui == oui) return oui_list[i].name; #endif @@ -153,15 +158,20 @@ static DEVICE_ATTR(tlabels_mask,S_IRUGO,fw_show_ne_tlabels_mask,NULL); -fw_attr(ne, struct node_entry, guid, unsigned long long, "0x%016Lx\n") fw_attr(ne, struct node_entry, capabilities, unsigned int, "0x%06x\n") -fw_attr(ne, struct node_entry, vendor_id, unsigned int, "0x%06x\n") fw_attr(ne, struct node_entry, nodeid, unsigned int, "0x%04x\n") + +fw_attr(ne, struct node_entry, vendor_id, unsigned int, "0x%06x\n") fw_attr(ne, struct node_entry, vendor_name, const char *, "%s\n") -fw_attr(ne, struct node_entry, oui_name, const char *, "%s\n") +fw_attr(ne, struct node_entry, vendor_oui, const char *, "%s\n") + +fw_attr(ne, struct node_entry, guid, unsigned long long, "0x%016Lx\n") +fw_attr(ne, struct node_entry, guid_vendor_id, unsigned int, "0x%06x\n") +fw_attr(ne, struct node_entry, guid_vendor_oui, const char *, "%s\n") static struct device_attribute *const fw_ne_attrs[] = { &dev_attr_ne_guid, + &dev_attr_ne_guid_vendor_id, &dev_attr_ne_capabilities, &dev_attr_ne_vendor_id, &dev_attr_ne_nodeid, @@ -175,12 +185,13 @@ fw_attr(ud, struct unit_directory, address, unsigned long long, "0x%016Lx\n") fw_attr(ud, struct unit_directory, length, int, "%d\n") -/* These are all dependent on if the value is preovided */ +/* These are all dependent on the value being provided */ fw_attr(ud, struct unit_directory, vendor_id, unsigned int, "0x%06x\n") fw_attr(ud, struct unit_directory, model_id, unsigned int, "0x%06x\n") fw_attr(ud, struct unit_directory, specifier_id, unsigned int, "0x%06x\n") fw_attr(ud, struct unit_directory, version, unsigned int, "0x%06x\n") fw_attr(ud, struct unit_directory, vendor_name, const char *, "%s\n") +fw_attr(ud, struct unit_directory, vendor_oui, const char *, "%s\n") fw_attr(ud, struct unit_directory, model_name, const char *, "%s\n") static struct device_attribute *const fw_ud_attrs[] = { @@ -401,8 +412,9 @@ } -static void nodemgr_remove_ud(struct device *dev) +static void nodemgr_remove_ud(struct unit_directory *ud) { + struct device *dev = &ud->device; int i; for (i = 0; i < ARRAY_SIZE(fw_ud_attrs); i++) @@ -412,6 +424,7 @@ device_remove_file(dev, &dev_attr_ud_version); device_remove_file(dev, &dev_attr_ud_vendor_id); device_remove_file(dev, &dev_attr_ud_vendor_name); + device_remove_file(dev, &dev_attr_ud_vendor_oui); device_remove_file(dev, &dev_attr_ud_model_id); device_remove_file(dev, &dev_attr_ud_model_name); @@ -419,17 +432,46 @@ } -static void nodemgr_remove_ne(struct device *dev) +static void nodemgr_remove_node_uds(struct node_entry *ne) { - int i; struct list_head *lh, *next; - list_for_each_safe(lh, next, &dev->children) - nodemgr_remove_ud(list_to_dev(lh)); + list_for_each_safe(lh, next, &ne->device.children) { + struct unit_directory *ud; + ud = container_of(list_to_dev(lh), struct unit_directory, device); + nodemgr_remove_ud(ud); + } +} + + +static void nodemgr_update_ud_names(struct host_info *hi, struct node_entry *ne) +{ + struct list_head *lh; + + list_for_each(lh, &ne->device.children) { + struct unit_directory *ud; + ud = container_of(list_to_dev(lh), struct unit_directory, device); + + sprintf(ud->device.name, "IEEE-1394 unit directory %d-" NODE_BUS_FMT "-%u", + hi->id, NODE_BUS_ARGS(ne->nodeid), ud->id); + } +} + + +static void nodemgr_remove_ne(struct node_entry *ne) +{ + struct device *dev = &ne->device; + int i; + + nodemgr_remove_node_uds(ne); for (i = 0; i < ARRAY_SIZE(fw_ne_attrs); i++) device_remove_file(dev, fw_ne_attrs[i]); + device_remove_file(dev, &dev_attr_ne_guid_vendor_oui); + device_remove_file(dev, &dev_attr_ne_vendor_name); + device_remove_file(dev, &dev_attr_ne_vendor_oui); + device_unregister(dev); } @@ -440,14 +482,9 @@ struct list_head *lh, *next; list_for_each_safe(lh, next, &dev->children) { - struct device *child_dev = list_to_dev(lh); struct node_entry *ne; - - ne = container_of(child_dev, struct node_entry, device); - /* Force free'ing of ne struct aswell */ - ne->device.release = nodemgr_release_ne; - - nodemgr_remove_ne(child_dev); + ne = container_of(list_to_dev(lh), struct node_entry, device); + nodemgr_remove_ne(ne); } for (i = 0; i < ARRAY_SIZE(fw_host_attrs); i++) @@ -467,6 +504,7 @@ static struct device nodemgr_dev_template_ne = { .bus = &ieee1394_bus_type, + .release = nodemgr_release_ne, .class_num = DEV_CLASS_NODE, }; @@ -622,8 +660,7 @@ memset(ne, 0, total_size); if (size != 0) { - ne->vendor_name - = (const char *) &(ne->quadlets[2]); + ne->vendor_name = (const char *) &(ne->quadlets[2]); ne->quadlets[size] = 0; } else { ne->vendor_name = NULL; @@ -650,15 +687,30 @@ ne->host = host; ne->nodeid = nodeid; - ne->guid = guid; ne->generation = generation; + ne->guid = guid; + ne->guid_vendor_id = (guid >> 40) & 0xffffff; + ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id); + memcpy(&ne->device, &nodemgr_dev_template_ne, sizeof(ne->device)); ne->device.parent = &host->device; + snprintf(ne->device.bus_id, BUS_ID_SIZE, FW_BUS_ID_FMT, + FW_BUS_ID_ARGS(hi, ne)); + sprintf(ne->device.name, "IEEE-1394 device %d-" NODE_BUS_FMT, + hi->id, NODE_BUS_ARGS(ne->nodeid)); + + device_register(&ne->device); + + if (ne->guid_vendor_oui) + device_create_file(&ne->device, &dev_attr_ne_guid_vendor_oui); + nodemgr_create_ne_dev_files(ne); nodemgr_process_config_rom (hi, ne, busoptions); + nodemgr_update_ud_names(hi, ne); + HPSB_DEBUG("%s added: ID:BUS[%d-" NODE_BUS_FMT "] GUID[%016Lx]", (host->node_id == nodeid) ? "Host" : "Node", hi->id, NODE_BUS_ARGS(nodeid), (unsigned long long)guid); @@ -842,7 +894,7 @@ /* This implementation currently only scans the config rom and its * immediate unit directories looking for software_id and * software_version entries, in order to get driver autoloading working. */ -static void nodemgr_process_unit_directory(struct node_entry *ne, +static void nodemgr_process_unit_directory(struct host_info *hi, struct node_entry *ne, octlet_t address, unsigned int id) { struct unit_directory *ud; @@ -879,6 +931,10 @@ case CONFIG_ROM_VENDOR_ID: ud->vendor_id = value; ud->flags |= UNIT_DIRECTORY_VENDOR_ID; + + if (ud->vendor_id) + ud->vendor_oui = nodemgr_find_oui_name(ud->vendor_id); + if ((ud->flags & UNIT_DIRECTORY_VENDOR_TEXT) != 0) { length--; address += 4; @@ -941,10 +997,13 @@ memcpy(&ud->device, &nodemgr_dev_template_ud, sizeof(ud->device)); ud->device.parent = &ne->device; - sprintf(ud->device.bus_id, "%s-%u", ne->device.bus_id, ud->id); - sprintf(ud->device.name, "IEEE-1394 unit directory %s", ud->device.bus_id); + snprintf(ud->device.bus_id, BUS_ID_SIZE, "%s-%u", + ne->device.bus_id, ud->id); + + device_register(&ud->device); - device_register(&ud->device); + if (ud->vendor_oui) + device_create_file(&ud->device, &dev_attr_ud_vendor_oui); nodemgr_create_ud_dev_files(ud); return; @@ -982,7 +1041,7 @@ return; } -static void nodemgr_process_root_directory(struct node_entry *ne) +static void nodemgr_process_root_directory(struct host_info *hi, struct node_entry *ne) { octlet_t address; quadlet_t quad; @@ -1015,9 +1074,8 @@ case CONFIG_ROM_VENDOR_ID: ne->vendor_id = value; - ne->oui_name = nodemgr_find_oui_name(value); - if (ne->oui_name) - device_create_file(&ne->device, &dev_attr_ne_oui_name); + if (ne->vendor_id) + ne->vendor_oui = nodemgr_find_oui_name(ne->vendor_id); /* Now check if there is a vendor name text string. */ @@ -1040,7 +1098,7 @@ break; case CONFIG_ROM_UNIT_DIRECTORY: - nodemgr_process_unit_directory(ne, address + value * 4, ud_id++); + nodemgr_process_unit_directory(hi, ne, address + value * 4, ud_id++); break; case CONFIG_ROM_DESCRIPTOR_LEAF: @@ -1183,14 +1241,12 @@ ne->busopt.cyc_clk_acc, ne->busopt.max_rec, ne->busopt.generation, ne->busopt.lnkspd); #endif + device_remove_file(&ne->device, &dev_attr_ne_vendor_oui); - sprintf(ne->device.bus_id, "%d-" NODE_BUS_FMT, hi->id, NODE_BUS_ARGS(ne->nodeid)); - sprintf(ne->device.name, "IEEE-1394 device %s", ne->device.bus_id); - - device_register(&ne->device); - nodemgr_create_ne_dev_files(ne); + nodemgr_process_root_directory(hi, ne); - nodemgr_process_root_directory(ne); + if (ne->vendor_oui) + device_create_file(&ne->device, &dev_attr_ne_vendor_oui); } @@ -1234,21 +1290,32 @@ struct host_info *hi, nodeid_t nodeid, unsigned int generation) { + int update_ud_names = 0; + if (ne->nodeid != nodeid) { + sprintf(ne->device.name, "IEEE-1394 device %d-" NODE_BUS_FMT, + hi->id, NODE_BUS_ARGS(ne->nodeid)); HPSB_DEBUG("Node " NODE_BUS_FMT " changed to " NODE_BUS_FMT, NODE_BUS_ARGS(ne->nodeid), NODE_BUS_ARGS(nodeid)); ne->nodeid = nodeid; + + update_ud_names++; } - /* If the node's configrom generation has changed, we unregister - * it, which in turn unregisters it's children (unit directories). */ if (ne->busopt.generation != ((busoptions >> 4) & 0xf)) { - nodemgr_remove_ne(&ne->device); + /* If the node's configrom generation has changed, we + * unregister all the unit directories. */ + nodemgr_remove_node_uds(ne); - /* This will re-register our node + ud's */ + /* This will re-register our unitdir's */ nodemgr_process_config_rom (hi, ne, busoptions); + + update_ud_names++; } + if (update_ud_names) + nodemgr_update_ud_names(hi, ne); + /* Since that's done, we can declare this record current */ ne->generation = generation; @@ -1440,15 +1507,20 @@ nodemgr_remove_node)) { struct node_entry *ne = cleanup.ne; - HPSB_DEBUG("Device removed: ID:BUS[%s] GUID[%016Lx]", - ne->device.bus_id, (unsigned long long)ne->guid); - - /* Causes ne to be free'd when the device isn't - * referenced anymore. */ - ne->device.release = nodemgr_release_ne; + HPSB_DEBUG("Device removed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", + NODE_BUS_ARGS(ne->nodeid), (unsigned long long)ne->guid); - nodemgr_remove_ne(&ne->device); + nodemgr_remove_ne(ne); } + + /* Now let's tell the bus to rescan our devices. This may + * seem like overhead, but the driver-model core will only + * scan a device for a driver when either the device is + * added, or when a new driver is added. A bus reset is a + * good reason to rescan devices that were there before. + * For example, an sbp2 device may become available for + * login, if the host that held it was just removed. */ + bus_rescan_devices(&ieee1394_bus_type); } return; Modified: trunk/nodemgr.h ============================================================================== --- trunk/nodemgr.h (original) +++ trunk/nodemgr.h 2003-03-11 21:44:06.000000000 -0500 @@ -100,8 +100,11 @@ struct node_entry *ne; /* The node which this directory belongs to */ octlet_t address; /* Address of the unit directory on the node */ u8 flags; /* Indicates which entries were read */ + quadlet_t vendor_id; const char *vendor_name; + const char *vendor_oui; + int vendor_name_size; quadlet_t model_id; const char *model_name; @@ -121,6 +124,9 @@ struct node_entry { u64 guid; /* GUID of this node */ + u32 guid_vendor_id; /* Top 24bits of guid */ + const char *guid_vendor_oui; /* OUI name of guid vendor id */ + struct hpsb_host *host; /* Host this node is attached to */ nodeid_t nodeid; /* NodeID */ struct bus_options busopt; /* Bus Options */ @@ -128,13 +134,13 @@ /* The following is read from the config rom */ u32 vendor_id; + const char *vendor_name; + const char *vendor_oui; + u32 capabilities; struct hpsb_tlabel_pool *tpool; - const char *vendor_name; - char *oui_name; - struct device device; /* XXX Must be last in the struct! */ Modified: trunk/TODO ============================================================================== --- trunk/TODO (original) +++ trunk/TODO 2003-03-11 21:44:06.000000000 -0500 @@ -15,10 +15,15 @@ - Multiple LUN support in SBP-2 +- Need to report driver attach for information purposes (like usb does). + Driver Model: +- Convert bus_id's to use guid (need BUS_ID strlen to be larger) + - the sbp2 devices (not the driver or host) need a symlink to the unitdir it is attached to. - sbp2 devices need dev attributes for sbp2 specific settings (speed, max - packet, etc.). I want to get rid of the proc file. + packet, etc.). I want to get rid of the proc file. Need to find a way to + hook into the scsi-dev layer. |