If you think to go to Tangier by ferry, you should know there are two ports: the Port of Tangier (in the city) and the port Tanger-Med (at 50km).
To reach to the port of Tanger-city you must take the ferry from the port of Tarifa. If you take the ferry from the port of Algeciras you will arrive at the port of Tanger-Med.
To enter in Morocco, valid passport is required for at least three months. The maximum stay permitted by law for tourists is three months a year. If you want to prolong it,you must go to the Moroccan police.