aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2014-04-02 16:28:49 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2014-04-07 04:48:55 -0400
commitd45aca42a25c4ba7a73115fcf2283ee1a822665e (patch)
tree33abf9b97aa066f72da1a0d057304d712b0e6ca5 /drivers/target
parentd2c5304c7ade0356c63e31f79a33452b3d4e3772 (diff)
target/spc: Only expose PI mode page bits when supported by fabric
Only expose the control modepage bit for Application Tag Owner (ATO) if the session + fabric support DIX PASS operations. Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Or Gerlitz <ogerlitz@mellanox.com> Cc: Quinn Tran <quinn.tran@qlogic.com> Cc: Giridhar Malavali <giridhar.malavali@qlogic.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_spc.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index d4c6a318d4c2..8653666612a8 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -769,7 +769,7 @@ out:
769 return ret; 769 return ret;
770} 770}
771 771
772static int spc_modesense_rwrecovery(struct se_device *dev, u8 pc, u8 *p) 772static int spc_modesense_rwrecovery(struct se_cmd *cmd, u8 pc, u8 *p)
773{ 773{
774 p[0] = 0x01; 774 p[0] = 0x01;
775 p[1] = 0x0a; 775 p[1] = 0x0a;
@@ -782,8 +782,11 @@ out:
782 return 12; 782 return 12;
783} 783}
784 784
785static int spc_modesense_control(struct se_device *dev, u8 pc, u8 *p) 785static int spc_modesense_control(struct se_cmd *cmd, u8 pc, u8 *p)
786{ 786{
787 struct se_device *dev = cmd->se_dev;
788 struct se_session *sess = cmd->se_sess;
789
787 p[0] = 0x0a; 790 p[0] = 0x0a;
788 p[1] = 0x0a; 791 p[1] = 0x0a;
789 792
@@ -875,8 +878,10 @@ static int spc_modesense_control(struct se_device *dev, u8 pc, u8 *p)
875 * type, shall not modify the contents of the LOGICAL BLOCK REFERENCE 878 * type, shall not modify the contents of the LOGICAL BLOCK REFERENCE
876 * TAG field. 879 * TAG field.
877 */ 880 */
878 if (dev->dev_attrib.pi_prot_type) 881 if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
879 p[5] |= 0x80; 882 if (dev->dev_attrib.pi_prot_type)
883 p[5] |= 0x80;
884 }
880 885
881 p[8] = 0xff; 886 p[8] = 0xff;
882 p[9] = 0xff; 887 p[9] = 0xff;
@@ -886,8 +891,10 @@ out:
886 return 12; 891 return 12;
887} 892}
888 893
889static int spc_modesense_caching(struct se_device *dev, u8 pc, u8 *p) 894static int spc_modesense_caching(struct se_cmd *cmd, u8 pc, u8 *p)
890{ 895{
896 struct se_device *dev = cmd->se_dev;
897
891 p[0] = 0x08; 898 p[0] = 0x08;
892 p[1] = 0x12; 899 p[1] = 0x12;
893 900
@@ -903,7 +910,7 @@ out:
903 return 20; 910 return 20;
904} 911}
905 912
906static int spc_modesense_informational_exceptions(struct se_device *dev, u8 pc, unsigned char *p) 913static int spc_modesense_informational_exceptions(struct se_cmd *cmd, u8 pc, unsigned char *p)
907{ 914{
908 p[0] = 0x1c; 915 p[0] = 0x1c;
909 p[1] = 0x0a; 916 p[1] = 0x0a;
@@ -919,7 +926,7 @@ out:
919static struct { 926static struct {
920 uint8_t page; 927 uint8_t page;
921 uint8_t subpage; 928 uint8_t subpage;
922 int (*emulate)(struct se_device *, u8, unsigned char *); 929 int (*emulate)(struct se_cmd *, u8, unsigned char *);
923} modesense_handlers[] = { 930} modesense_handlers[] = {
924 { .page = 0x01, .subpage = 0x00, .emulate = spc_modesense_rwrecovery }, 931 { .page = 0x01, .subpage = 0x00, .emulate = spc_modesense_rwrecovery },
925 { .page = 0x08, .subpage = 0x00, .emulate = spc_modesense_caching }, 932 { .page = 0x08, .subpage = 0x00, .emulate = spc_modesense_caching },
@@ -1057,7 +1064,7 @@ static sense_reason_t spc_emulate_modesense(struct se_cmd *cmd)
1057 * the only two possibilities). 1064 * the only two possibilities).
1058 */ 1065 */
1059 if ((modesense_handlers[i].subpage & ~subpage) == 0) { 1066 if ((modesense_handlers[i].subpage & ~subpage) == 0) {
1060 ret = modesense_handlers[i].emulate(dev, pc, &buf[length]); 1067 ret = modesense_handlers[i].emulate(cmd, pc, &buf[length]);
1061 if (!ten && length + ret >= 255) 1068 if (!ten && length + ret >= 255)
1062 break; 1069 break;
1063 length += ret; 1070 length += ret;
@@ -1070,7 +1077,7 @@ static sense_reason_t spc_emulate_modesense(struct se_cmd *cmd)
1070 for (i = 0; i < ARRAY_SIZE(modesense_handlers); ++i) 1077 for (i = 0; i < ARRAY_SIZE(modesense_handlers); ++i)
1071 if (modesense_handlers[i].page == page && 1078 if (modesense_handlers[i].page == page &&
1072 modesense_handlers[i].subpage == subpage) { 1079 modesense_handlers[i].subpage == subpage) {
1073 length += modesense_handlers[i].emulate(dev, pc, &buf[length]); 1080 length += modesense_handlers[i].emulate(cmd, pc, &buf[length]);
1074 goto set_length; 1081 goto set_length;
1075 } 1082 }
1076 1083
@@ -1102,7 +1109,6 @@ set_length:
1102 1109
1103static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd) 1110static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
1104{ 1111{
1105 struct se_device *dev = cmd->se_dev;
1106 char *cdb = cmd->t_task_cdb; 1112 char *cdb = cmd->t_task_cdb;
1107 bool ten = cdb[0] == MODE_SELECT_10; 1113 bool ten = cdb[0] == MODE_SELECT_10;
1108 int off = ten ? 8 : 4; 1114 int off = ten ? 8 : 4;
@@ -1138,7 +1144,7 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
1138 if (modesense_handlers[i].page == page && 1144 if (modesense_handlers[i].page == page &&
1139 modesense_handlers[i].subpage == subpage) { 1145 modesense_handlers[i].subpage == subpage) {
1140 memset(tbuf, 0, SE_MODE_PAGE_BUF); 1146 memset(tbuf, 0, SE_MODE_PAGE_BUF);
1141 length = modesense_handlers[i].emulate(dev, 0, tbuf); 1147 length = modesense_handlers[i].emulate(cmd, 0, tbuf);
1142 goto check_contents; 1148 goto check_contents;
1143 } 1149 }
1144 1150