VirtualBox

source: vbox/trunk/src/VBox/Devices/USB/VUSBInternal.h@ 55901

Last change on this file since 55901 was 55901, checked in by vboxsync, 10 years ago

USB: Fix attaching multiple devices to the same roothub on xHCI

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.9 KB
Line 
1/* $Id: VUSBInternal.h 55901 2015-05-18 10:39:35Z vboxsync $ */
2/** @file
3 * Virtual USB - Internal header.
4 *
5 * This subsystem implements USB devices in a host controller independent
6 * way. All the host controller code has to do is use VUSBHUB for its
7 * root hub implementation and any emulated USB device may be plugged into
8 * the virtual bus.
9 */
10
11/*
12 * Copyright (C) 2006-2011 Oracle Corporation
13 *
14 * This file is part of VirtualBox Open Source Edition (OSE), as
15 * available from http://www.virtualbox.org. This file is free software;
16 * you can redistribute it and/or modify it under the terms of the GNU
17 * General Public License (GPL) as published by the Free Software
18 * Foundation, in version 2 as it comes in the "COPYING" file of the
19 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
20 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
21 */
22
23#ifndef ___VUSBInternal_h
24#define ___VUSBInternal_h
25
26#include <VBox/cdefs.h>
27#include <VBox/types.h>
28#include <VBox/vusb.h>
29#include <VBox/vmm/stam.h>
30#include <iprt/assert.h>
31#include <iprt/queueatomic.h>
32#include <iprt/req.h>
33
34#include "VUSBSniffer.h"
35
36RT_C_DECLS_BEGIN
37
38
39/** @name Internal Device Operations, Structures and Constants.
40 * @{
41 */
42
43/** Pointer to a Virtual USB device (core). */
44typedef struct VUSBDEV *PVUSBDEV;
45/** Pointer to a VUSB hub device. */
46typedef struct VUSBHUB *PVUSBHUB;
47/** Pointer to a VUSB root hub. */
48typedef struct VUSBROOTHUB *PVUSBROOTHUB;
49
50
51/** Number of the default control endpoint */
52#define VUSB_PIPE_DEFAULT 0
53
54/** @name Device addresses
55 * @{ */
56#define VUSB_DEFAULT_ADDRESS 0
57#define VUSB_INVALID_ADDRESS UINT8_C(0xff)
58/** @} */
59
60/** @name Feature bits (1<<FEATURE for the u16Status bit)
61 * @{ */
62#define VUSB_DEV_SELF_POWERED 0
63#define VUSB_DEV_REMOTE_WAKEUP 1
64#define VUSB_EP_HALT 0
65/** @} */
66
67/** Maximum number of endpoint addresses */
68#define VUSB_PIPE_MAX 16
69
70/**
71 * Control-pipe stages.
72 */
73typedef enum CTLSTAGE
74{
75 /** the control pipe is in the setup stage. */
76 CTLSTAGE_SETUP = 0,
77 /** the control pipe is in the data stage. */
78 CTLSTAGE_DATA,
79 /** the control pipe is in the status stage. */
80 CTLSTAGE_STATUS
81} CTLSTAGE;
82
83/**
84 * Extra data for a control pipe.
85 *
86 * This is state information needed for the special multi-stage
87 * transfers performed on this kind of pipes.
88 */
89typedef struct vusb_ctrl_extra
90{
91 /** Current pipe stage. */
92 CTLSTAGE enmStage;
93 /** Success indicator. */
94 bool fOk;
95 /** Set if the message URB has been submitted. */
96 bool fSubmitted;
97 /** Pointer to the SETUP.
98 * This is a pointer to Urb->abData[0]. */
99 PVUSBSETUP pMsg;
100 /** Current DATA pointer.
101 * This starts at pMsg + 1 and is incremented at we read/write data. */
102 uint8_t *pbCur;
103 /** The amount of data left to read on IN operations.
104 * On OUT operations this is not used. */
105 uint32_t cbLeft;
106 /** The amount of data we can house.
107 * This starts at the default 8KB, and this structure will be reallocated to
108 * accommodate any larger request (unlikely). */
109 uint32_t cbMax;
110 /** The message URB. */
111 VUSBURB Urb;
112} VUSBCTRLEXTRA, *PVUSBCTRLEXTRA;
113
114void vusbMsgFreeExtraData(PVUSBCTRLEXTRA pExtra);
115void vusbMsgResetExtraData(PVUSBCTRLEXTRA pExtra);
116
117/** Opaque VUSB read ahead buffer management handle. */
118typedef struct VUSBREADAHEADINT *VUSBREADAHEAD;
119
120/**
121 * A VUSB pipe
122 */
123typedef struct vusb_pipe
124{
125 PCVUSBDESCENDPOINTEX in;
126 PCVUSBDESCENDPOINTEX out;
127 /** Pointer to the extra state data required to run a control pipe. */
128 PVUSBCTRLEXTRA pCtrl;
129 /** Critical section serializing access to the extra state data for a control pipe. */
130 RTCRITSECT CritSectCtrl;
131 /** Count of active async transfers. */
132 volatile uint32_t async;
133 /** Read ahead handle. */
134 VUSBREADAHEAD hReadAhead;
135} VUSBPIPE;
136/** Pointer to a VUSB pipe structure. */
137typedef VUSBPIPE *PVUSBPIPE;
138
139
140/**
141 * Interface state and possible settings.
142 */
143typedef struct vusb_interface_state
144{
145 /** Pointer to the interface descriptor of the currently selected (active)
146 * interface. */
147 PCVUSBDESCINTERFACEEX pCurIfDesc;
148 /** Pointer to the interface settings. */
149 PCVUSBINTERFACE pIf;
150} VUSBINTERFACESTATE;
151/** Pointer to interface state. */
152typedef VUSBINTERFACESTATE *PVUSBINTERFACESTATE;
153/** Pointer to const interface state. */
154typedef const VUSBINTERFACESTATE *PCVUSBINTERFACESTATE;
155
156
157/**
158 * A Virtual USB device (core).
159 *
160 * @implements VUSBIDEVICE
161 */
162typedef struct VUSBDEV
163{
164 /** The device interface exposed to the HCI. */
165 VUSBIDEVICE IDevice;
166 /** Pointer to the PDM USB device instance. */
167 PPDMUSBINS pUsbIns;
168 /** Next device in the chain maintained by the roothub. */
169 PVUSBDEV pNext;
170 /** Pointer to the next device with the same address hash. */
171 PVUSBDEV pNextHash;
172 /** Pointer to the hub this device is attached to. */
173 PVUSBHUB pHub;
174 /** The device state. */
175 VUSBDEVICESTATE volatile enmState;
176
177 /** The device address. */
178 uint8_t u8Address;
179 /** The new device address. */
180 uint8_t u8NewAddress;
181 /** The port. */
182 int16_t i16Port;
183 /** Device status. (VUSB_DEV_SELF_POWERED or not.) */
184 uint16_t u16Status;
185
186 /** Pointer to the descriptor cache.
187 * (Provided by the device thru the pfnGetDescriptorCache method.) */
188 PCPDMUSBDESCCACHE pDescCache;
189 /** Current configuration. */
190 PCVUSBDESCCONFIGEX pCurCfgDesc;
191
192 /** Current interface state (including alternate interface setting) - maximum
193 * valid index is config->bNumInterfaces
194 */
195 PVUSBINTERFACESTATE paIfStates;
196
197 /** Pipe/direction -> endpoint descriptor mapping */
198 VUSBPIPE aPipes[VUSB_PIPE_MAX];
199 /** Critical section protecting the active URB list. */
200 RTCRITSECT CritSectAsyncUrbs;
201 /** List of active async URBs. */
202 PVUSBURB pAsyncUrbHead;
203
204 /** Dumper state. */
205 union VUSBDEVURBDUMPERSTATE
206 {
207 /** The current scsi command. */
208 uint8_t u8ScsiCmd;
209 } Urb;
210
211 /** The reset timer handle. */
212 PTMTIMER pResetTimer;
213 /** Reset handler arguments. */
214 void *pvArgs;
215 /** URB submit and reap thread. */
216 RTTHREAD hUrbIoThread;
217 /** Request queue for executing tasks on the I/O thread which should be done
218 * synchronous and without any other thread accessing the USB device. */
219 RTREQQUEUE hReqQueueSync;
220 /** Sniffer instance for this device if configured. */
221 VUSBSNIFFER hSniffer;
222 /** Flag whether the URB I/O thread should terminate. */
223 bool volatile fTerminate;
224 /** Flag whether the I/O thread was woken up. */
225 bool volatile fWokenUp;
226#if HC_ARCH_BITS == 32
227 /** Align the size to a 8 byte boundary. */
228 bool afAlignment0[2];
229#endif
230} VUSBDEV;
231AssertCompileSizeAlignment(VUSBDEV, 8);
232
233
234/** Pointer to the virtual method table for a kind of USB devices. */
235typedef struct vusb_dev_ops *PVUSBDEVOPS;
236
237/** Pointer to the const virtual method table for a kind of USB devices. */
238typedef const struct vusb_dev_ops *PCVUSBDEVOPS;
239
240/**
241 * Virtual method table for USB devices - these are the functions you need to
242 * implement when writing a new device (or hub)
243 *
244 * Note that when creating your structure, you are required to zero the
245 * vusb_dev fields (ie. use calloc).
246 */
247typedef struct vusb_dev_ops
248{
249 /* mandatory */
250 const char *name;
251} VUSBDEVOPS;
252
253
254int vusbDevInit(PVUSBDEV pDev, PPDMUSBINS pUsbIns, const char *pszCaptureFilename);
255int vusbDevCreateOld(const char *pszDeviceName, void *pvDriverInit, PCRTUUID pUuid, PVUSBDEV *ppDev);
256void vusbDevDestroy(PVUSBDEV pDev);
257
258DECLINLINE(bool) vusbDevIsRh(PVUSBDEV pDev)
259{
260 return (pDev->pHub == (PVUSBHUB)pDev);
261}
262
263bool vusbDevDoSelectConfig(PVUSBDEV dev, PCVUSBDESCCONFIGEX pCfg);
264void vusbDevMapEndpoint(PVUSBDEV dev, PCVUSBDESCENDPOINTEX ep);
265int vusbDevDetach(PVUSBDEV pDev);
266DECLINLINE(PVUSBROOTHUB) vusbDevGetRh(PVUSBDEV pDev);
267size_t vusbDevMaxInterfaces(PVUSBDEV dev);
268
269void vusbDevSetAddress(PVUSBDEV pDev, uint8_t u8Address);
270bool vusbDevStandardRequest(PVUSBDEV pDev, int EndPt, PVUSBSETUP pSetup, void *pvBuf, uint32_t *pcbBuf);
271
272
273/** @} */
274
275
276
277
278
279/** @name Internal Hub Operations, Structures and Constants.
280 * @{
281 */
282
283
284/** Virtual method table for USB hub devices.
285 * Hub and roothub drivers need to implement these functions in addition to the
286 * vusb_dev_ops.
287 */
288typedef struct VUSBHUBOPS
289{
290 int (*pfnAttach)(PVUSBHUB pHub, PVUSBDEV pDev);
291 void (*pfnDetach)(PVUSBHUB pHub, PVUSBDEV pDev);
292} VUSBHUBOPS;
293/** Pointer to a const HUB method table. */
294typedef const VUSBHUBOPS *PCVUSBHUBOPS;
295
296/** A VUSB Hub Device - Hub and roothub drivers need to use this struct
297 * @todo eliminate this (PDM / roothubs only).
298 */
299typedef struct VUSBHUB
300{
301 VUSBDEV Dev;
302 PCVUSBHUBOPS pOps;
303 PVUSBROOTHUB pRootHub;
304 uint16_t cPorts;
305 uint16_t cDevices;
306 /** Name of the hub. Used for logging. */
307 char *pszName;
308} VUSBHUB;
309AssertCompileMemberAlignment(VUSBHUB, pOps, 8);
310AssertCompileSizeAlignment(VUSBHUB, 8);
311
312/** @} */
313
314
315/** @name Internal Root Hub Operations, Structures and Constants.
316 * @{
317 */
318
319/**
320 * Per transfer type statistics.
321 */
322typedef struct VUSBROOTHUBTYPESTATS
323{
324 STAMCOUNTER StatUrbsSubmitted;
325 STAMCOUNTER StatUrbsFailed;
326 STAMCOUNTER StatUrbsCancelled;
327
328 STAMCOUNTER StatReqBytes;
329 STAMCOUNTER StatReqReadBytes;
330 STAMCOUNTER StatReqWriteBytes;
331
332 STAMCOUNTER StatActBytes;
333 STAMCOUNTER StatActReadBytes;
334 STAMCOUNTER StatActWriteBytes;
335} VUSBROOTHUBTYPESTATS, *PVUSBROOTHUBTYPESTATS;
336
337
338
339/** The address hash table size. */
340#define VUSB_ADDR_HASHSZ 5
341
342/**
343 * The instance data of a root hub driver.
344 *
345 * This extends the generic VUSB hub.
346 *
347 * @implements VUSBIROOTHUBCONNECTOR
348 */
349typedef struct VUSBROOTHUB
350{
351 /** The HUB.
352 * @todo remove this? */
353 VUSBHUB Hub;
354 /** Address hash table. */
355 PVUSBDEV apAddrHash[VUSB_ADDR_HASHSZ];
356
357#if HC_ARCH_BITS == 32
358 uint32_t Alignment0;
359#endif
360
361 /** Pointer to the driver instance. */
362 PPDMDRVINS pDrvIns;
363 /** Pointer to the root hub port interface we're attached to. */
364 PVUSBIROOTHUBPORT pIRhPort;
365 /** Connector interface exposed upwards. */
366 VUSBIROOTHUBCONNECTOR IRhConnector;
367
368#if HC_ARCH_BITS == 32
369 uint32_t Alignment1;
370#endif
371
372 /** Critical section protecting the device list. */
373 RTCRITSECT CritSectDevices;
374 /** Chain of devices attached to this hub. */
375 PVUSBDEV pDevices;
376
377#if HC_ARCH_BITS == 32
378 uint32_t Alignment2;
379#endif
380
381 /** Availability Bitmap. */
382 VUSBPORTBITMAP Bitmap;
383
384 /** Critical section protecting the free list. */
385 RTCRITSECT CritSectFreeUrbs;
386 /** Chain of free URBs. (Singly linked) */
387 PVUSBURB pFreeUrbs;
388 /** Sniffer instance for the root hub. */
389 VUSBSNIFFER hSniffer;
390 /** The number of URBs in the pool. */
391 uint32_t cUrbsInPool;
392 /** Version of the attached Host Controller. */
393 uint32_t fHcVersions;
394#ifdef VBOX_WITH_STATISTICS
395 VUSBROOTHUBTYPESTATS Total;
396 VUSBROOTHUBTYPESTATS aTypes[VUSBXFERTYPE_MSG];
397 STAMCOUNTER StatIsocReqPkts;
398 STAMCOUNTER StatIsocReqReadPkts;
399 STAMCOUNTER StatIsocReqWritePkts;
400 STAMCOUNTER StatIsocActPkts;
401 STAMCOUNTER StatIsocActReadPkts;
402 STAMCOUNTER StatIsocActWritePkts;
403 struct
404 {
405 STAMCOUNTER Pkts;
406 STAMCOUNTER Ok;
407 STAMCOUNTER Ok0;
408 STAMCOUNTER DataUnderrun;
409 STAMCOUNTER DataUnderrun0;
410 STAMCOUNTER DataOverrun;
411 STAMCOUNTER NotAccessed;
412 STAMCOUNTER Misc;
413 STAMCOUNTER Bytes;
414 } aStatIsocDetails[8];
415
416 STAMPROFILE StatReapAsyncUrbs;
417 STAMPROFILE StatSubmitUrb;
418#endif
419} VUSBROOTHUB;
420AssertCompileMemberAlignment(VUSBROOTHUB, IRhConnector, 8);
421AssertCompileMemberAlignment(VUSBROOTHUB, Bitmap, 8);
422AssertCompileMemberAlignment(VUSBROOTHUB, CritSectDevices, 8);
423AssertCompileMemberAlignment(VUSBROOTHUB, CritSectFreeUrbs, 8);
424#ifdef VBOX_WITH_STATISTICS
425AssertCompileMemberAlignment(VUSBROOTHUB, Total, 8);
426#endif
427
428/** Converts a pointer to VUSBROOTHUB::IRhConnector to a PVUSBROOTHUB. */
429#define VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface) (PVUSBROOTHUB)( (uintptr_t)(pInterface) - RT_OFFSETOF(VUSBROOTHUB, IRhConnector) )
430
431/**
432 * URB cancellation modes
433 */
434typedef enum CANCELMODE
435{
436 /** complete the URB with an error (CRC). */
437 CANCELMODE_FAIL = 0,
438 /** do not change the URB contents. */
439 CANCELMODE_UNDO
440} CANCELMODE;
441
442/* @} */
443
444
445
446/** @name Internal URB Operations, Structures and Constants.
447 * @{ */
448int vusbUrbSubmit(PVUSBURB pUrb);
449void vusbUrbTrace(PVUSBURB pUrb, const char *pszMsg, bool fComplete);
450void vusbUrbDoReapAsync(PVUSBURB pHead, RTMSINTERVAL cMillies);
451void vusbUrbDoReapAsyncDev(PVUSBDEV pDev, RTMSINTERVAL cMillies);
452void vusbUrbCancel(PVUSBURB pUrb, CANCELMODE mode);
453void vusbUrbCancelAsync(PVUSBURB pUrb, CANCELMODE mode);
454void vusbUrbRipe(PVUSBURB pUrb);
455void vusbUrbCompletionRh(PVUSBURB pUrb);
456int vusbUrbSubmitHardError(PVUSBURB pUrb);
457int vusbUrbErrorRh(PVUSBURB pUrb);
458int vusbDevUrbIoThreadWakeup(PVUSBDEV pDev);
459int vusbDevUrbIoThreadCreate(PVUSBDEV pDev);
460int vusbDevUrbIoThreadDestroy(PVUSBDEV pDev);
461DECLHIDDEN(int) vusbDevIoThreadExecV(PVUSBDEV pDev, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args);
462DECLHIDDEN(int) vusbDevIoThreadExec(PVUSBDEV pDev, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
463DECLHIDDEN(int) vusbDevIoThreadExecSync(PVUSBDEV pDev, PFNRT pfnFunction, unsigned cArgs, ...);
464DECLHIDDEN(int) vusbUrbCancelWorker(PVUSBURB pUrb, CANCELMODE enmMode);
465
466void vusbUrbCompletionReadAhead(PVUSBURB pUrb);
467VUSBREADAHEAD vusbReadAheadStart(PVUSBDEV pDev, PVUSBPIPE pPipe);
468void vusbReadAheadStop(VUSBREADAHEAD hReadAhead);
469int vusbUrbQueueAsyncRh(PVUSBURB pUrb);
470int vusbUrbSubmitBufferedRead(PVUSBURB pUrb, VUSBREADAHEAD hReadAhead);
471PVUSBURB vusbRhNewUrb(PVUSBROOTHUB pRh, uint8_t DstAddress, uint32_t cbData, uint32_t cTds);
472
473
474DECLINLINE(void) vusbUrbUnlink(PVUSBURB pUrb)
475{
476 PVUSBDEV pDev = pUrb->VUsb.pDev;
477
478 RTCritSectEnter(&pDev->CritSectAsyncUrbs);
479 *pUrb->VUsb.ppPrev = pUrb->VUsb.pNext;
480 if (pUrb->VUsb.pNext)
481 pUrb->VUsb.pNext->VUsb.ppPrev = pUrb->VUsb.ppPrev;
482 pUrb->VUsb.pNext = NULL;
483 pUrb->VUsb.ppPrev = NULL;
484 RTCritSectLeave(&pDev->CritSectAsyncUrbs);
485}
486
487/** @def vusbUrbAssert
488 * Asserts that a URB is valid.
489 */
490#ifdef VBOX_STRICT
491# define vusbUrbAssert(pUrb) do { \
492 AssertMsg(VALID_PTR((pUrb)), ("%p\n", (pUrb))); \
493 AssertMsg((pUrb)->u32Magic == VUSBURB_MAGIC, ("%#x", (pUrb)->u32Magic)); \
494 AssertMsg((pUrb)->enmState > VUSBURBSTATE_INVALID && (pUrb)->enmState < VUSBURBSTATE_END, \
495 ("%d\n", (pUrb)->enmState)); \
496 } while (0)
497#else
498# define vusbUrbAssert(pUrb) do {} while (0)
499#endif
500
501/**
502 * @def VUSBDEV_ASSERT_VALID_STATE
503 * Asserts that the give device state is valid.
504 */
505#define VUSBDEV_ASSERT_VALID_STATE(enmState) \
506 AssertMsg((enmState) > VUSB_DEVICE_STATE_INVALID && (enmState) < VUSB_DEVICE_STATE_DESTROYED, ("enmState=%#x\n", enmState));
507
508/** Executes a function synchronously. */
509#define VUSB_DEV_IO_THREAD_EXEC_FLAGS_SYNC RT_BIT_32(0)
510
511/** @} */
512
513
514
515
516/**
517 * Addresses are between 0 and 127 inclusive
518 */
519DECLINLINE(uint8_t) vusbHashAddress(uint8_t Address)
520{
521 uint8_t u8Hash = Address;
522 u8Hash ^= (Address >> 2);
523 u8Hash ^= (Address >> 3);
524 u8Hash %= VUSB_ADDR_HASHSZ;
525 return u8Hash;
526}
527
528
529/**
530 * Gets the roothub of a device.
531 *
532 * @returns Pointer to the roothub instance the device is attached to.
533 * @returns NULL if not attached to any hub.
534 * @param pDev Pointer to the device in question.
535 */
536DECLINLINE(PVUSBROOTHUB) vusbDevGetRh(PVUSBDEV pDev)
537{
538 if (!pDev->pHub)
539 return NULL;
540 return pDev->pHub->pRootHub;
541}
542
543
544/**
545 * Returns the state of the USB device.
546 *
547 * @returns State of the USB device.
548 * @param pDev Pointer to the device.
549 */
550DECLINLINE(VUSBDEVICESTATE) vusbDevGetState(PVUSBDEV pDev)
551{
552 VUSBDEVICESTATE enmState = (VUSBDEVICESTATE)ASMAtomicReadU32((volatile uint32_t *)&pDev->enmState);
553 VUSBDEV_ASSERT_VALID_STATE(enmState);
554 return enmState;
555}
556
557
558/**
559 * Sets the given state for the USB device.
560 *
561 * @returns The old state of the device.
562 * @param pDev Pointer to the device.
563 * @param enmState The new state to set.
564 */
565DECLINLINE(VUSBDEVICESTATE) vusbDevSetState(PVUSBDEV pDev, VUSBDEVICESTATE enmState)
566{
567 VUSBDEV_ASSERT_VALID_STATE(enmState);
568 VUSBDEVICESTATE enmStateOld = (VUSBDEVICESTATE)ASMAtomicXchgU32((volatile uint32_t *)&pDev->enmState, enmState);
569 VUSBDEV_ASSERT_VALID_STATE(enmStateOld);
570 return enmStateOld;
571}
572
573
574/**
575 * Compare and exchange the states for the given USB device.
576 *
577 * @returns true if the state was changed.
578 * @returns false if the state wasn't changed.
579 * @param pDev Pointer to the device.
580 * @param enmStateNew The new state to set.
581 * @param enmStateOld The old state to compare with.
582 */
583DECLINLINE(bool) vusbDevSetStateCmp(PVUSBDEV pDev, VUSBDEVICESTATE enmStateNew, VUSBDEVICESTATE enmStateOld)
584{
585 VUSBDEV_ASSERT_VALID_STATE(enmStateNew);
586 VUSBDEV_ASSERT_VALID_STATE(enmStateOld);
587 return ASMAtomicCmpXchgU32((volatile uint32_t *)&pDev->enmState, enmStateNew, enmStateOld);
588}
589
590/** Strings for the CTLSTAGE enum values. */
591extern const char * const g_apszCtlStates[4];
592/** Default message pipe. */
593extern const VUSBDESCENDPOINTEX g_Endpoint0;
594/** Default configuration. */
595extern const VUSBDESCCONFIGEX g_Config0;
596
597RT_C_DECLS_END
598#endif
599
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette