mps_user.c (251396) | mps_user.c (253460) |
---|---|
1/*- 2 * Copyright (c) 2008 Yahoo!, Inc. 3 * All rights reserved. 4 * Written by: John Baldwin <jhb@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 42 unchanged lines hidden (view full) --- 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 55 * SUCH DAMAGE. 56 * 57 * LSI MPT-Fusion Host Adapter FreeBSD 58 * | 1/*- 2 * Copyright (c) 2008 Yahoo!, Inc. 3 * All rights reserved. 4 * Written by: John Baldwin <jhb@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 42 unchanged lines hidden (view full) --- 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 55 * SUCH DAMAGE. 56 * 57 * LSI MPT-Fusion Host Adapter FreeBSD 58 * |
59 * $FreeBSD: head/sys/dev/mps/mps_user.c 251396 2013-06-04 22:32:33Z asomers $ | 59 * $FreeBSD: head/sys/dev/mps/mps_user.c 253460 2013-07-19 00:12:41Z scottl $ |
60 */ 61 62#include <sys/cdefs.h> | 60 */ 61 62#include <sys/cdefs.h> |
63__FBSDID("$FreeBSD: head/sys/dev/mps/mps_user.c 251396 2013-06-04 22:32:33Z asomers $"); | 63__FBSDID("$FreeBSD: head/sys/dev/mps/mps_user.c 253460 2013-07-19 00:12:41Z scottl $"); |
64 65#include "opt_compat.h" 66 67/* TODO Move headers to mpsvar */ 68#include <sys/types.h> 69#include <sys/param.h> 70#include <sys/systm.h> 71#include <sys/kernel.h> --- 600 unchanged lines hidden (view full) --- 672 mps_printf(sc, "mps_user_command: no mps requests\n"); 673 err = ENOMEM; 674 goto Ret; 675 } 676 mps_unlock(sc); 677 678 hdr = (MPI2_REQUEST_HEADER *)cm->cm_req; 679 | 64 65#include "opt_compat.h" 66 67/* TODO Move headers to mpsvar */ 68#include <sys/types.h> 69#include <sys/param.h> 70#include <sys/systm.h> 71#include <sys/kernel.h> --- 600 unchanged lines hidden (view full) --- 672 mps_printf(sc, "mps_user_command: no mps requests\n"); 673 err = ENOMEM; 674 goto Ret; 675 } 676 mps_unlock(sc); 677 678 hdr = (MPI2_REQUEST_HEADER *)cm->cm_req; 679 |
680 mps_dprint(sc, MPS_INFO, "mps_user_command: req %p %d rpl %p %d\n", | 680 mps_dprint(sc, MPS_USER, "mps_user_command: req %p %d rpl %p %d\n", |
681 cmd->req, cmd->req_len, cmd->rpl, cmd->rpl_len ); 682 683 if (cmd->req_len > (int)sc->facts->IOCRequestFrameSize * 4) { 684 err = EINVAL; 685 goto RetFreeUnlocked; 686 } 687 err = copyin(cmd->req, hdr, cmd->req_len); 688 if (err != 0) 689 goto RetFreeUnlocked; 690 | 681 cmd->req, cmd->req_len, cmd->rpl, cmd->rpl_len ); 682 683 if (cmd->req_len > (int)sc->facts->IOCRequestFrameSize * 4) { 684 err = EINVAL; 685 goto RetFreeUnlocked; 686 } 687 err = copyin(cmd->req, hdr, cmd->req_len); 688 if (err != 0) 689 goto RetFreeUnlocked; 690 |
691 mps_dprint(sc, MPS_INFO, "mps_user_command: Function %02X " | 691 mps_dprint(sc, MPS_USER, "mps_user_command: Function %02X " |
692 "MsgFlags %02X\n", hdr->Function, hdr->MsgFlags ); 693 694 if (cmd->len > 0) { 695 buf = malloc(cmd->len, M_MPSUSER, M_WAITOK|M_ZERO); 696 if(!buf) { 697 mps_printf(sc, "Cannot allocate memory %s %d\n", 698 __func__, __LINE__); 699 return (ENOMEM); --- 37 unchanged lines hidden (view full) --- 737 err = EINVAL; 738 sz = cmd->rpl_len; 739 } 740 741 mps_unlock(sc); 742 copyout(rpl, cmd->rpl, sz); 743 if (buf != NULL) 744 copyout(buf, cmd->buf, cmd->len); | 692 "MsgFlags %02X\n", hdr->Function, hdr->MsgFlags ); 693 694 if (cmd->len > 0) { 695 buf = malloc(cmd->len, M_MPSUSER, M_WAITOK|M_ZERO); 696 if(!buf) { 697 mps_printf(sc, "Cannot allocate memory %s %d\n", 698 __func__, __LINE__); 699 return (ENOMEM); --- 37 unchanged lines hidden (view full) --- 737 err = EINVAL; 738 sz = cmd->rpl_len; 739 } 740 741 mps_unlock(sc); 742 copyout(rpl, cmd->rpl, sz); 743 if (buf != NULL) 744 copyout(buf, cmd->buf, cmd->len); |
745 mps_dprint(sc, MPS_INFO, "mps_user_command: reply size %d\n", sz ); | 745 mps_dprint(sc, MPS_USER, "mps_user_command: reply size %d\n", sz ); |
746 747RetFreeUnlocked: 748 mps_lock(sc); 749 if (cm != NULL) 750 mps_free_command(sc, cm); 751Ret: 752 mps_unlock(sc); 753 if (buf != NULL) --- 12 unchanged lines hidden (view full) --- 766 u_int sense_len; 767 768 /* 769 * Only allow one passthru command at a time. Use the MPS_FLAGS_BUSY 770 * bit to denote that a passthru is being processed. 771 */ 772 mps_lock(sc); 773 if (sc->mps_flags & MPS_FLAGS_BUSY) { | 746 747RetFreeUnlocked: 748 mps_lock(sc); 749 if (cm != NULL) 750 mps_free_command(sc, cm); 751Ret: 752 mps_unlock(sc); 753 if (buf != NULL) --- 12 unchanged lines hidden (view full) --- 766 u_int sense_len; 767 768 /* 769 * Only allow one passthru command at a time. Use the MPS_FLAGS_BUSY 770 * bit to denote that a passthru is being processed. 771 */ 772 mps_lock(sc); 773 if (sc->mps_flags & MPS_FLAGS_BUSY) { |
774 mps_dprint(sc, MPS_INFO, "%s: Only one passthru command " | 774 mps_dprint(sc, MPS_USER, "%s: Only one passthru command " |
775 "allowed at a single time.", __func__); 776 mps_unlock(sc); 777 return (EBUSY); 778 } 779 sc->mps_flags |= MPS_FLAGS_BUSY; 780 mps_unlock(sc); 781 782 /* --- 15 unchanged lines hidden (view full) --- 798 (data->DataOutSize != 0))))) { 799 if (data->DataDirection == MPS_PASS_THRU_DIRECTION_BOTH) 800 data->DataDirection = MPS_PASS_THRU_DIRECTION_READ; 801 else 802 data->DataOutSize = 0; 803 } else 804 return (EINVAL); 805 | 775 "allowed at a single time.", __func__); 776 mps_unlock(sc); 777 return (EBUSY); 778 } 779 sc->mps_flags |= MPS_FLAGS_BUSY; 780 mps_unlock(sc); 781 782 /* --- 15 unchanged lines hidden (view full) --- 798 (data->DataOutSize != 0))))) { 799 if (data->DataDirection == MPS_PASS_THRU_DIRECTION_BOTH) 800 data->DataDirection = MPS_PASS_THRU_DIRECTION_READ; 801 else 802 data->DataOutSize = 0; 803 } else 804 return (EINVAL); 805 |
806 mps_dprint(sc, MPS_INFO, "%s: req 0x%jx %d rpl 0x%jx %d " | 806 mps_dprint(sc, MPS_USER, "%s: req 0x%jx %d rpl 0x%jx %d " |
807 "data in 0x%jx %d data out 0x%jx %d data dir %d\n", __func__, 808 data->PtrRequest, data->RequestSize, data->PtrReply, 809 data->ReplySize, data->PtrData, data->DataSize, 810 data->PtrDataOut, data->DataOutSize, data->DataDirection); 811 812 /* 813 * copy in the header so we know what we're dealing with before we 814 * commit to allocating a command for it. 815 */ 816 err = copyin(PTRIN(data->PtrRequest), &tmphdr, data->RequestSize); 817 if (err != 0) 818 goto RetFreeUnlocked; 819 820 if (data->RequestSize > (int)sc->facts->IOCRequestFrameSize * 4) { 821 err = EINVAL; 822 goto RetFreeUnlocked; 823 } 824 825 function = tmphdr.Function; | 807 "data in 0x%jx %d data out 0x%jx %d data dir %d\n", __func__, 808 data->PtrRequest, data->RequestSize, data->PtrReply, 809 data->ReplySize, data->PtrData, data->DataSize, 810 data->PtrDataOut, data->DataOutSize, data->DataDirection); 811 812 /* 813 * copy in the header so we know what we're dealing with before we 814 * commit to allocating a command for it. 815 */ 816 err = copyin(PTRIN(data->PtrRequest), &tmphdr, data->RequestSize); 817 if (err != 0) 818 goto RetFreeUnlocked; 819 820 if (data->RequestSize > (int)sc->facts->IOCRequestFrameSize * 4) { 821 err = EINVAL; 822 goto RetFreeUnlocked; 823 } 824 825 function = tmphdr.Function; |
826 mps_dprint(sc, MPS_INFO, "%s: Function %02X MsgFlags %02X\n", __func__, | 826 mps_dprint(sc, MPS_USER, "%s: Function %02X MsgFlags %02X\n", __func__, |
827 function, tmphdr.MsgFlags); 828 829 /* 830 * Handle a passthru TM request. 831 */ 832 if (function == MPI2_FUNCTION_SCSI_TASK_MGMT) { 833 MPI2_SCSI_TASK_MANAGE_REQUEST *task; 834 --- 412 unchanged lines hidden (view full) --- 1247 struct mps_command *cm = NULL; 1248 int status; 1249 1250 /* 1251 * If buffer is not enabled, just leave. 1252 */ 1253 *return_code = MPS_FW_DIAG_ERROR_RELEASE_FAILED; 1254 if (!pBuffer->enabled) { | 827 function, tmphdr.MsgFlags); 828 829 /* 830 * Handle a passthru TM request. 831 */ 832 if (function == MPI2_FUNCTION_SCSI_TASK_MGMT) { 833 MPI2_SCSI_TASK_MANAGE_REQUEST *task; 834 --- 412 unchanged lines hidden (view full) --- 1247 struct mps_command *cm = NULL; 1248 int status; 1249 1250 /* 1251 * If buffer is not enabled, just leave. 1252 */ 1253 *return_code = MPS_FW_DIAG_ERROR_RELEASE_FAILED; 1254 if (!pBuffer->enabled) { |
1255 mps_dprint(sc, MPS_INFO, "%s: This buffer type is not supported " | 1255 mps_dprint(sc, MPS_USER, "%s: This buffer type is not supported " |
1256 "by the IOC", __func__); 1257 return (MPS_DIAG_FAILURE); 1258 } 1259 1260 /* 1261 * Clear some flags initially. 1262 */ 1263 pBuffer->force_release = FALSE; --- 526 unchanged lines hidden (view full) --- 1790mps_user_diag_action(struct mps_softc *sc, mps_diag_action_t *data) 1791{ 1792 int status; 1793 1794 /* 1795 * Only allow one diag action at one time. 1796 */ 1797 if (sc->mps_flags & MPS_FLAGS_BUSY) { | 1256 "by the IOC", __func__); 1257 return (MPS_DIAG_FAILURE); 1258 } 1259 1260 /* 1261 * Clear some flags initially. 1262 */ 1263 pBuffer->force_release = FALSE; --- 526 unchanged lines hidden (view full) --- 1790mps_user_diag_action(struct mps_softc *sc, mps_diag_action_t *data) 1791{ 1792 int status; 1793 1794 /* 1795 * Only allow one diag action at one time. 1796 */ 1797 if (sc->mps_flags & MPS_FLAGS_BUSY) { |
1798 mps_dprint(sc, MPS_INFO, "%s: Only one FW diag command " | 1798 mps_dprint(sc, MPS_USER, "%s: Only one FW diag command " |
1799 "allowed at a single time.", __func__); 1800 return (EBUSY); 1801 } 1802 sc->mps_flags |= MPS_FLAGS_BUSY; 1803 1804 /* 1805 * Send diag action request 1806 */ --- 170 unchanged lines hidden (view full) --- 1977 int status = 0; 1978 1979 switch (data->Command) { 1980 /* 1981 * IO access is not supported. 1982 */ 1983 case REG_IO_READ: 1984 case REG_IO_WRITE: | 1799 "allowed at a single time.", __func__); 1800 return (EBUSY); 1801 } 1802 sc->mps_flags |= MPS_FLAGS_BUSY; 1803 1804 /* 1805 * Send diag action request 1806 */ --- 170 unchanged lines hidden (view full) --- 1977 int status = 0; 1978 1979 switch (data->Command) { 1980 /* 1981 * IO access is not supported. 1982 */ 1983 case REG_IO_READ: 1984 case REG_IO_WRITE: |
1985 mps_dprint(sc, MPS_INFO, "IO access is not supported. " | 1985 mps_dprint(sc, MPS_USER, "IO access is not supported. " |
1986 "Use memory access."); 1987 status = EINVAL; 1988 break; 1989 1990 case REG_MEM_READ: 1991 data->RegData = mps_regread(sc, data->RegOffset); 1992 break; 1993 --- 171 unchanged lines hidden (view full) --- 2165 /* Sleep for 300 second. */ 2166 msleep_ret = msleep(&sc->port_enable_complete, &sc->mps_mtx, PRIBIO, 2167 "mps_porten", 300 * hz); 2168 mps_unlock(sc); 2169 if (msleep_ret) 2170 printf("Port Enable did not complete after Diag " 2171 "Reset msleep error %d.\n", msleep_ret); 2172 else | 1986 "Use memory access."); 1987 status = EINVAL; 1988 break; 1989 1990 case REG_MEM_READ: 1991 data->RegData = mps_regread(sc, data->RegOffset); 1992 break; 1993 --- 171 unchanged lines hidden (view full) --- 2165 /* Sleep for 300 second. */ 2166 msleep_ret = msleep(&sc->port_enable_complete, &sc->mps_mtx, PRIBIO, 2167 "mps_porten", 300 * hz); 2168 mps_unlock(sc); 2169 if (msleep_ret) 2170 printf("Port Enable did not complete after Diag " 2171 "Reset msleep error %d.\n", msleep_ret); 2172 else |
2173 mps_dprint(sc, MPS_INFO, | 2173 mps_dprint(sc, MPS_USER, |
2174 "Hard Reset with Port Enable completed in %d seconds.\n", 2175 (uint32_t) (time_uptime - reinit_start)); 2176 break; 2177 case MPTIOCTL_DIAG_ACTION: 2178 /* 2179 * The user has done a diag buffer action. Call our routine 2180 * which does this. Only allow one diag action at one time. 2181 */ --- 246 unchanged lines hidden --- | 2174 "Hard Reset with Port Enable completed in %d seconds.\n", 2175 (uint32_t) (time_uptime - reinit_start)); 2176 break; 2177 case MPTIOCTL_DIAG_ACTION: 2178 /* 2179 * The user has done a diag buffer action. Call our routine 2180 * which does this. Only allow one diag action at one time. 2181 */ --- 246 unchanged lines hidden --- |