1*71e72c9eSCy Schubert /* 2*71e72c9eSCy Schubert * NAN NDP/NDL state machine testing definitions 3*71e72c9eSCy Schubert * Copyright (C) 2025 Intel Corporation 4*71e72c9eSCy Schubert * 5*71e72c9eSCy Schubert * This software may be distributed under the terms of the BSD license. 6*71e72c9eSCy Schubert * See README for more details. 7*71e72c9eSCy Schubert */ 8*71e72c9eSCy Schubert 9*71e72c9eSCy Schubert #ifndef NAN_MODULE_TESTS_H 10*71e72c9eSCy Schubert #define NAN_MODULE_TESTS_H 11*71e72c9eSCy Schubert 12*71e72c9eSCy Schubert #define NAN_TEST_NAME_MAX 32 13*71e72c9eSCy Schubert 14*71e72c9eSCy Schubert /** 15*71e72c9eSCy Schubert * enum nan_test_ndp_notify_type - NDP notification 16*71e72c9eSCy Schubert * NAN_TEST_NDP_NOTIFY_INVALID: Invalid 17*71e72c9eSCy Schubert * NAN_TEST_NDP_NOTIFY_REQUEST: NDP request 18*71e72c9eSCy Schubert * NAN_TEST_NDP_NOTIFY_RESPONSE: NDP response 19*71e72c9eSCy Schubert * NAN_TEST_NDP_NOTIFY_CONNECTED: NDP connected 20*71e72c9eSCy Schubert * NAN_TEST_NDP_NOTIFY_DISCONNECTED: NDP disconnected 21*71e72c9eSCy Schubert */ 22*71e72c9eSCy Schubert enum nan_test_ndp_notify_type { 23*71e72c9eSCy Schubert NAN_TEST_NDP_NOTIFY_INVALID, 24*71e72c9eSCy Schubert NAN_TEST_NDP_NOTIFY_REQUEST, 25*71e72c9eSCy Schubert NAN_TEST_NDP_NOTIFY_RESPONSE, 26*71e72c9eSCy Schubert NAN_TEST_NDP_NOTIFY_CONNECTED, 27*71e72c9eSCy Schubert NAN_TEST_NDP_NOTIFY_DISCONNECTED, 28*71e72c9eSCy Schubert }; 29*71e72c9eSCy Schubert 30*71e72c9eSCy Schubert #define NAN_TEST_MAX_POT_AVAIL 256 31*71e72c9eSCy Schubert #define NAN_MAX_NUM_NDPS 8 32*71e72c9eSCy Schubert 33*71e72c9eSCy Schubert /** 34*71e72c9eSCy Schubert * nan_test_dev_conf - NAN test device configuration 35*71e72c9eSCy Schubert * @schedule_cb: Callback to configure different schedule handling policies 36*71e72c9eSCy Schubert * for a device for initial request and response. 37*71e72c9eSCy Schubert * @schedule_conf_cb: Callback to configure different schedule handling 38*71e72c9eSCy Schubert * policies for a device for confirmation. 39*71e72c9eSCy Schubert * @get_chans_cb: Callback to configure different channels for potential 40*71e72c9eSCy Schubert * availability. 41*71e72c9eSCy Schubert * @pot_avail: Device potential availability 42*71e72c9eSCy Schubert * @pot_avail_len: Length of the device potential availability 43*71e72c9eSCy Schubert * @n_ndps: Number of NDP configurations (to support scenarios that involve 44*71e72c9eSCy Schubert * establishing multiple NDPs in a single test case). 45*71e72c9eSCy Schubert * @ndp_confs: Array of NDP configurations. 46*71e72c9eSCy Schubert * @accept_request: For publisher device, indicates whether to accept an NDP 47*71e72c9eSCy Schubert * request or reject it. For subscriber device, indicates whether to accept 48*71e72c9eSCy Schubert * an NDP response or reject it. 49*71e72c9eSCy Schubert * @term_once_connected: Terminate once connected. 50*71e72c9eSCy Schubert * @expected_result: Expected NDP establishment result 51*71e72c9eSCy Schubert * @reason: For publisher device, indicates the reject reason 52*71e72c9eSCy Schubert * @csid: Cipher suite ID 53*71e72c9eSCy Schubert * @expected_csid: Expected Cipher suite ID in case of a successful connection 54*71e72c9eSCy Schubert * @pmk: Pairwise Master Key 55*71e72c9eSCy Schubert */ 56*71e72c9eSCy Schubert struct nan_test_dev_conf { 57*71e72c9eSCy Schubert int (*schedule_cb)(struct nan_schedule *sched); 58*71e72c9eSCy Schubert int (*schedule_conf_cb)(struct nan_schedule *sched); 59*71e72c9eSCy Schubert int (*get_chans_cb)(struct nan_channels *chans); 60*71e72c9eSCy Schubert 61*71e72c9eSCy Schubert u8 pot_avail[NAN_TEST_MAX_POT_AVAIL]; 62*71e72c9eSCy Schubert size_t pot_avail_len; 63*71e72c9eSCy Schubert 64*71e72c9eSCy Schubert size_t n_ndps; 65*71e72c9eSCy Schubert struct ndp_conf { 66*71e72c9eSCy Schubert bool accept_request; 67*71e72c9eSCy Schubert bool term_once_connected; 68*71e72c9eSCy Schubert enum nan_test_ndp_notify_type expected_result; 69*71e72c9eSCy Schubert u8 reason; 70*71e72c9eSCy Schubert enum nan_cipher_suite_id csid; 71*71e72c9eSCy Schubert enum nan_cipher_suite_id expected_csid; 72*71e72c9eSCy Schubert } ndp_confs[NAN_MAX_NUM_NDPS]; 73*71e72c9eSCy Schubert 74*71e72c9eSCy Schubert u8 pmk[PMK_LEN]; 75*71e72c9eSCy Schubert }; 76*71e72c9eSCy Schubert 77*71e72c9eSCy Schubert /** 78*71e72c9eSCy Schubert * nan_device - Represents a NAN test device 79*71e72c9eSCy Schubert * @list: Used for global devices list 80*71e72c9eSCy Schubert * @global: Pointer to NAN test global data structure 81*71e72c9eSCy Schubert * @name: Test device name 82*71e72c9eSCy Schubert * @nmi: Test device NMI 83*71e72c9eSCy Schubert * @ndi: Test device NDI 84*71e72c9eSCy Schubert * @counter: Device counter for NDP various purposes 85*71e72c9eSCy Schubert * @pot_avail: Device potential availability 86*71e72c9eSCy Schubert * @pot_avail_len: Length of the device potential availability 87*71e72c9eSCy Schubert * @nan: Pointer to NAN data structure 88*71e72c9eSCy Schubert * @conf: NAN test device configuration 89*71e72c9eSCy Schubert * @n_ndps: Number of NDPs established so far minus one 90*71e72c9eSCy Schubert * @connected_notify_received: Indicates whether a connected notification 91*71e72c9eSCy Schubert * was received 92*71e72c9eSCy Schubert * @disconnected_notify_received: Indicates whether a disconnected notification 93*71e72c9eSCy Schubert * was received 94*71e72c9eSCy Schubert * @tk: NAN TK 95*71e72c9eSCy Schubert * @tk_len: Length of the NAN TK 96*71e72c9eSCy Schubert * @csid: Cipher suite ID 97*71e72c9eSCy Schubert */ 98*71e72c9eSCy Schubert struct nan_device { 99*71e72c9eSCy Schubert struct dl_list list; 100*71e72c9eSCy Schubert struct nan_test_global *global; 101*71e72c9eSCy Schubert 102*71e72c9eSCy Schubert u8 name[NAN_TEST_NAME_MAX]; 103*71e72c9eSCy Schubert u8 nmi[ETH_ALEN]; 104*71e72c9eSCy Schubert u8 ndi[ETH_ALEN]; 105*71e72c9eSCy Schubert u32 counter; 106*71e72c9eSCy Schubert 107*71e72c9eSCy Schubert u8 *pot_avail; 108*71e72c9eSCy Schubert size_t pot_avail_len; 109*71e72c9eSCy Schubert 110*71e72c9eSCy Schubert struct nan_data *nan; 111*71e72c9eSCy Schubert const struct nan_test_dev_conf *conf; 112*71e72c9eSCy Schubert 113*71e72c9eSCy Schubert size_t n_ndps; 114*71e72c9eSCy Schubert 115*71e72c9eSCy Schubert bool connected_notify_received; 116*71e72c9eSCy Schubert bool disconnected_notify_received; 117*71e72c9eSCy Schubert 118*71e72c9eSCy Schubert u8 tk[NAN_TK_MAX_LEN]; 119*71e72c9eSCy Schubert size_t tk_len; 120*71e72c9eSCy Schubert enum nan_cipher_suite_id csid; 121*71e72c9eSCy Schubert }; 122*71e72c9eSCy Schubert 123*71e72c9eSCy Schubert /** 124*71e72c9eSCy Schubert * nan_test_case - Single NAN test configuration 125*71e72c9eSCy Schubert * @name: Test name 126*71e72c9eSCy Schubert * @pub_conf: Publisher test configuration 127*71e72c9eSCy Schubert * @sub_conf: Subscriber test configuration 128*71e72c9eSCy Schubert */ 129*71e72c9eSCy Schubert struct nan_test_case { 130*71e72c9eSCy Schubert const char *name; 131*71e72c9eSCy Schubert struct nan_test_dev_conf pub_conf; 132*71e72c9eSCy Schubert struct nan_test_dev_conf sub_conf; 133*71e72c9eSCy Schubert }; 134*71e72c9eSCy Schubert 135*71e72c9eSCy Schubert const struct nan_test_case * nan_test_case_get_next(void); 136*71e72c9eSCy Schubert 137*71e72c9eSCy Schubert #endif /* NAN_MODULE_TESTS_H */ 138