mpt.c (102304) | mpt.c (102822) |
---|---|
1/* $FreeBSD: head/sys/dev/mpt/mpt.c 102304 2002-08-23 06:56:31Z mjacob $ */ | 1/* $FreeBSD: head/sys/dev/mpt/mpt.c 102822 2002-09-01 23:07:09Z mjacob $ */ |
2/* 3 * Generic routines for LSI '909 FC adapters. 4 * FreeBSD Version. 5 * 6 * Copyright (c) 2000, 2001 by Greg Ansley 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 494 unchanged lines hidden (view full) --- 504 505 506/* 507 * Utiltity routine to read configuration headers and pages 508 */ 509 510static int 511mpt_read_cfg_header(mpt_softc_t *, int, int, int, fCONFIG_PAGE_HEADER *); | 2/* 3 * Generic routines for LSI '909 FC adapters. 4 * FreeBSD Version. 5 * 6 * Copyright (c) 2000, 2001 by Greg Ansley 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 494 unchanged lines hidden (view full) --- 504 505 506/* 507 * Utiltity routine to read configuration headers and pages 508 */ 509 510static int 511mpt_read_cfg_header(mpt_softc_t *, int, int, int, fCONFIG_PAGE_HEADER *); |
512static int 513mpt_read_cfg_page(mpt_softc_t *, int, fCONFIG_PAGE_HEADER *); 514static int 515mpt_write_cfg_page(mpt_softc_t *, int, fCONFIG_PAGE_HEADER *); | |
516 517static int 518mpt_read_cfg_header(mpt_softc_t *mpt, int PageType, int PageNumber, 519 int PageAddress, fCONFIG_PAGE_HEADER *rslt) 520{ 521 int count; 522 request_t *req; 523 MSG_CONFIG *cfgp; --- 36 unchanged lines hidden (view full) --- 560 bcopy(&reply->Header, rslt, sizeof (fCONFIG_PAGE_HEADER)); 561 mpt_free_reply(mpt, (req->sequence << 1)); 562 mpt_free_request(mpt, req); 563 return (0); 564} 565 566#define CFG_DATA_OFF 40 567 | 512 513static int 514mpt_read_cfg_header(mpt_softc_t *mpt, int PageType, int PageNumber, 515 int PageAddress, fCONFIG_PAGE_HEADER *rslt) 516{ 517 int count; 518 request_t *req; 519 MSG_CONFIG *cfgp; --- 36 unchanged lines hidden (view full) --- 556 bcopy(&reply->Header, rslt, sizeof (fCONFIG_PAGE_HEADER)); 557 mpt_free_reply(mpt, (req->sequence << 1)); 558 mpt_free_request(mpt, req); 559 return (0); 560} 561 562#define CFG_DATA_OFF 40 563 |
568static int | 564int |
569mpt_read_cfg_page(mpt_softc_t *mpt, int PageAddress, fCONFIG_PAGE_HEADER *hdr) 570{ 571 int count; 572 request_t *req; 573 SGE_SIMPLE32 *se; 574 MSG_CONFIG *cfgp; 575 size_t amt; 576 MSG_CONFIG_REPLY *reply; --- 55 unchanged lines hidden (view full) --- 632 cfgp->Header.PageNumber == 1) { 633 amt = sizeof (fCONFIG_PAGE_SCSI_DEVICE_1); 634 } 635 bcopy(((caddr_t)req->req_vbuf)+CFG_DATA_OFF, hdr, amt); 636 mpt_free_request(mpt, req); 637 return (0); 638} 639 | 565mpt_read_cfg_page(mpt_softc_t *mpt, int PageAddress, fCONFIG_PAGE_HEADER *hdr) 566{ 567 int count; 568 request_t *req; 569 SGE_SIMPLE32 *se; 570 MSG_CONFIG *cfgp; 571 size_t amt; 572 MSG_CONFIG_REPLY *reply; --- 55 unchanged lines hidden (view full) --- 628 cfgp->Header.PageNumber == 1) { 629 amt = sizeof (fCONFIG_PAGE_SCSI_DEVICE_1); 630 } 631 bcopy(((caddr_t)req->req_vbuf)+CFG_DATA_OFF, hdr, amt); 632 mpt_free_request(mpt, req); 633 return (0); 634} 635 |
640static int | 636int |
641mpt_write_cfg_page(mpt_softc_t *mpt, int PageAddress, fCONFIG_PAGE_HEADER *hdr) 642{ 643 int count, hdr_attr; 644 request_t *req; 645 SGE_SIMPLE32 *se; 646 MSG_CONFIG *cfgp; 647 size_t amt; 648 MSG_CONFIG_REPLY *reply; --- 231 unchanged lines hidden (view full) --- 880 * 881 * In particular, validate SPI Port Page 1. 882 */ 883static int 884mpt_set_initial_config_spi(mpt_softc_t *mpt) 885{ 886 int i, pp1val = ((1 << mpt->mpt_ini_id) << 16) | mpt->mpt_ini_id; 887 | 637mpt_write_cfg_page(mpt_softc_t *mpt, int PageAddress, fCONFIG_PAGE_HEADER *hdr) 638{ 639 int count, hdr_attr; 640 request_t *req; 641 SGE_SIMPLE32 *se; 642 MSG_CONFIG *cfgp; 643 size_t amt; 644 MSG_CONFIG_REPLY *reply; --- 231 unchanged lines hidden (view full) --- 876 * 877 * In particular, validate SPI Port Page 1. 878 */ 879static int 880mpt_set_initial_config_spi(mpt_softc_t *mpt) 881{ 882 int i, pp1val = ((1 << mpt->mpt_ini_id) << 16) | mpt->mpt_ini_id; 883 |
884 mpt->mpt_disc_enable = 0xff; 885 mpt->mpt_tag_enable = 0; 886 |
|
888 if (mpt->mpt_port_page1.Configuration != pp1val) { 889 fCONFIG_PAGE_SCSI_PORT_1 tmp; 890 device_printf(mpt->dev, 891 "SPI Port Page 1 Config value bad (%x)- should be %x\n", 892 mpt->mpt_port_page1.Configuration, pp1val); 893 tmp = mpt->mpt_port_page1; 894 tmp.Configuration = pp1val; 895 if (mpt_write_cfg_page(mpt, 0, &tmp.Header)) { --- 5 unchanged lines hidden (view full) --- 901 if (tmp.Configuration != pp1val) { 902 device_printf(mpt->dev, 903 "failed to reset SPI Port Page 1 Config value\n"); 904 return (-1); 905 } 906 mpt->mpt_port_page1 = tmp; 907 } 908 | 887 if (mpt->mpt_port_page1.Configuration != pp1val) { 888 fCONFIG_PAGE_SCSI_PORT_1 tmp; 889 device_printf(mpt->dev, 890 "SPI Port Page 1 Config value bad (%x)- should be %x\n", 891 mpt->mpt_port_page1.Configuration, pp1val); 892 tmp = mpt->mpt_port_page1; 893 tmp.Configuration = pp1val; 894 if (mpt_write_cfg_page(mpt, 0, &tmp.Header)) { --- 5 unchanged lines hidden (view full) --- 900 if (tmp.Configuration != pp1val) { 901 device_printf(mpt->dev, 902 "failed to reset SPI Port Page 1 Config value\n"); 903 return (-1); 904 } 905 mpt->mpt_port_page1 = tmp; 906 } 907 |
909#if 1 910 i = i; 911#else | |
912 for (i = 0; i < 16; i++) { 913 fCONFIG_PAGE_SCSI_DEVICE_1 tmp; 914 tmp = mpt->mpt_dev_page1[i]; 915 tmp.RequestedParameters = 0; 916 tmp.Configuration = 0; 917 if (mpt->verbose > 1) { 918 device_printf(mpt->dev, 919 "Set Tgt %d SPI DevicePage 1 values to %x 0 %x\n", --- 8 unchanged lines hidden (view full) --- 928 mpt->mpt_dev_page1[i] = tmp; 929 if (mpt->verbose > 1) { 930 device_printf(mpt->dev, 931 "SPI Tgt %d Page 1: RParm %x Configuration %x\n", i, 932 mpt->mpt_dev_page1[i].RequestedParameters, 933 mpt->mpt_dev_page1[i].Configuration); 934 } 935 } | 908 for (i = 0; i < 16; i++) { 909 fCONFIG_PAGE_SCSI_DEVICE_1 tmp; 910 tmp = mpt->mpt_dev_page1[i]; 911 tmp.RequestedParameters = 0; 912 tmp.Configuration = 0; 913 if (mpt->verbose > 1) { 914 device_printf(mpt->dev, 915 "Set Tgt %d SPI DevicePage 1 values to %x 0 %x\n", --- 8 unchanged lines hidden (view full) --- 924 mpt->mpt_dev_page1[i] = tmp; 925 if (mpt->verbose > 1) { 926 device_printf(mpt->dev, 927 "SPI Tgt %d Page 1: RParm %x Configuration %x\n", i, 928 mpt->mpt_dev_page1[i].RequestedParameters, 929 mpt->mpt_dev_page1[i].Configuration); 930 } 931 } |
936#endif | 932 933 /* 934 * If the BIOS hasn't been enabled, the SCSI Port Page2 device 935 * parameter are apparently complete nonsense. I've had partially 936 * sensible Page2 settings on *one* bus, but nothing on another- 937 * it's ridiculous. 938 * 939 * For that matter, the Port Page 0 parameters are *also* nonsense, 940 * so the offset and period and currently connected physical interface 941 * is also nonsense. 942 * 943 * This makes it very difficult to try and figure out what maximum 944 * settings we could have. Therefore, we'll synthesize the maximums 945 * here. 946 */ 947 for (i = 0; i < 16; i++) { 948 mpt->mpt_port_page2.DeviceSettings[i].DeviceFlags = 949 MPI_SCSIPORTPAGE2_DEVICE_DISCONNECT_ENABLE | 950 MPI_SCSIPORTPAGE2_DEVICE_TAG_QUEUE_ENABLE; 951 } 952 mpt->mpt_port_page0.Capabilities = 953 MPI_SCSIPORTPAGE0_CAP_IU | 954 MPI_SCSIPORTPAGE0_CAP_DT | 955 MPI_SCSIPORTPAGE0_CAP_QAS | 956 MPI_SCSIPORTPAGE0_CAP_WIDE | 957 (31 << 16) | /* offset */ 958 (8 << 8); /* period */ 959 mpt->mpt_port_page0.PhysicalInterface = 960 MPI_SCSIPORTPAGE0_PHY_SIGNAL_LVD; |
937 return (0); 938} 939 940/* 941 * Enable IOC port 942 */ 943static int 944mpt_send_port_enable(mpt_softc_t *mpt, int port) --- 111 unchanged lines hidden (view full) --- 1056 case MPT_DB_STATE_FAULT: 1057 if (mpt_reset(mpt) != MPT_OK) { 1058 return (EIO); 1059 } 1060 default: 1061 break; 1062 } 1063 | 961 return (0); 962} 963 964/* 965 * Enable IOC port 966 */ 967static int 968mpt_send_port_enable(mpt_softc_t *mpt, int port) --- 111 unchanged lines hidden (view full) --- 1080 case MPT_DB_STATE_FAULT: 1081 if (mpt_reset(mpt) != MPT_OK) { 1082 return (EIO); 1083 } 1084 default: 1085 break; 1086 } 1087 |
1064 | |
1065 for (try = 0; try < MPT_MAX_TRYS; try++) { 1066 /* 1067 * No need to reset if the IOC is already in the READY state. 1068 * 1069 * Force reset if initialization failed previously. 1070 * Note that a hard_reset of the second channel of a '929 1071 * will stop operation of the first channel. Hopefully, if the 1072 * first channel is ok, the second will not require a hard --- 131 unchanged lines hidden --- | 1088 for (try = 0; try < MPT_MAX_TRYS; try++) { 1089 /* 1090 * No need to reset if the IOC is already in the READY state. 1091 * 1092 * Force reset if initialization failed previously. 1093 * Note that a hard_reset of the second channel of a '929 1094 * will stop operation of the first channel. Hopefully, if the 1095 * first channel is ok, the second will not require a hard --- 131 unchanged lines hidden --- |