Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/zcrypt: enable card/domain autoselect on ep11 cprbs

For EP11 CPRBs there was only to choose between specify
one or more ep11 targets or not give a target at all. Without
any target the zcrypt code assumed AUTOSELECT. For EP11 this
ended up in choosing any EP11 APQN with regards to the weight.

However, CCA CPRBs can have a more fine granular target
addressing. The caller can give 0xFFFF as AUTOSELECT for
the card and/or the domain. So it's possible to address
any card but domain given or any domain but card given.

This patch now introduces the very same for EP11 CPRB handling.
An EP11 target entry now may contain 0xFFFF as card and/or
domain value with the meaning of ANY card or domain. So
now the same behavior as with CCA CPRBs becomes possible:
Address any card with given domain or address any domain within
given card.

For convenience the zcrypt.h header file now has two new
defines AUTOSEL_AP and AUTOSEL_DOM covering the 0xFFFF
value to address card any and domain any.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Harald Freudenberger and committed by
Vasily Gorbik
8f291ebf 7f820d05

+10 -5
+3 -1
arch/s390/include/uapi/asm/zcrypt.h
··· 237 237 struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT]; 238 238 }; 239 239 240 - #define AUTOSELECT 0xFFFFFFFF 240 + #define AUTOSELECT 0xFFFFFFFF 241 + #define AUTOSEL_AP ((__u16) 0xFFFF) 242 + #define AUTOSEL_DOM ((__u16) 0xFFFF) 241 243 242 244 #define ZCRYPT_IOCTL_MAGIC 'z' 243 245
+7 -4
drivers/s390/crypto/zcrypt_api.c
··· 849 849 /* check if device is online and eligible */ 850 850 if (!zq->online || 851 851 !zq->ops->send_cprb || 852 - (tdom != (unsigned short) AUTOSELECT && 852 + (tdom != AUTOSEL_DOM && 853 853 tdom != AP_QID_QUEUE(zq->queue->qid))) 854 854 continue; 855 855 /* check if device node has admission for this queue */ ··· 874 874 875 875 /* in case of auto select, provide the correct domain */ 876 876 qid = pref_zq->queue->qid; 877 - if (*domain == (unsigned short) AUTOSELECT) 877 + if (*domain == AUTOSEL_DOM) 878 878 *domain = AP_QID_QUEUE(qid); 879 879 880 880 rc = pref_zq->ops->send_cprb(pref_zq, xcRB, &ap_msg); ··· 901 901 struct ep11_target_dev *targets) 902 902 { 903 903 while (target_num-- > 0) { 904 - if (dev_id == targets->ap_id) 904 + if (targets->ap_id == dev_id || targets->ap_id == AUTOSEL_AP) 905 905 return true; 906 906 targets++; 907 907 } ··· 912 912 unsigned short target_num, 913 913 struct ep11_target_dev *targets) 914 914 { 915 + int card = AP_QID_CARD(dev_qid), dom = AP_QID_QUEUE(dev_qid); 916 + 915 917 while (target_num-- > 0) { 916 - if (AP_MKQID(targets->ap_id, targets->dom_id) == dev_qid) 918 + if ((targets->ap_id == card || targets->ap_id == AUTOSEL_AP) && 919 + (targets->dom_id == dom || targets->dom_id == AUTOSEL_DOM)) 917 920 return true; 918 921 targets++; 919 922 }